-1

I am trying to POST some data to Django App but every variable is working fine except one..

This is my form:

<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">&nbsp;&nbsp;
        <button type="button" style="margin:0;padding:0;" onclick="javascript:submitCoupon();">Submit Coupon</button>
        </div>
        </form>
    </div>

My JavaScript is:

<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>

3つの変数のうち、機能していますが機能couponCodecouponDiscountていませんstore_Name...変数名、IDを変更しようとしましたが、何も機能していません警告しようとするとstore_Name、未定義になります....また、コンソールにエラーが表示されません...

4

1 に答える 1