-1
我想一些POST數據到Django應用程序,但只是一個每一個變量是工作的罰款..Django應用程序的JavaScript的getElementById不工作
這是我的形式:
<div class="subfield">
<span>
Found a coupon for <b><span style="color:#d95b44;" id="Store_Name">{{ storeData.0.storeName }}</span>?</b>
Enter the details below to share with other users
</span>
<form>
<br>
<label for="user">Coupon code :</label>
<input type="text" id="coupon_Code" maxlength="100" />
<br>
<label for="user">Discount :</label>
<textarea rows="2" cols="19" minlength="15" id="coupon_Discount"></textarea>
<br>
<div id="buttn">
<button type="button" style="margin:0;padding:0;" onclick="javascript:submitCoupon();">Submit Coupon</button>
</div>
</form>
</div>
我的JavaScript是:
<script type="text/javascript">
function submitCoupon()
{
var store_Name = document.getElementById('Store_Name').value;
var couponCode = document.getElementById('coupon_Code').value;
var couponDiscount = document.getElementById('coupon_Discount').value;
var data = {"storeName":store_Name,"couponCode":couponCode,"couponDiscount":couponDiscount,
csrfmiddlewaretoken:'{{ csrf_token }}'};
alert(store_Name);
$.ajax({ // create an AJAX call...
data: data, // get the form data
type: "POST", // GET or POST
url: "/submit_coupon/", // the file to call
dataType: "json",
success: function(response) { // on success..
alert("done");
}
});
}
</script>
出三個變量couponCode
和couponDiscount
是工作,但沒有store_Name
... 我已經試過了變化摹變量名,ID,但沒有什麼工作 每當我試圖提醒store_Name
我越來越不確定.... 並且還控制檯顯示沒有錯誤......在使用
我不好使我''.value'的跨度...現在我試着'.innerHTML',它正在工作... – 2013-05-03 07:01:19