[英]could not update amount as i want to input
please help for me wrong code. 请为我提供错误代码。 I have created a ajax onClick function but credit amount do not update. 我已经创建了一个ajax onClick函数,但是信用额没有更新。 What is the problem ? 问题是什么 ?
<script type="text/javascript"> function togglediv(id) { var div = document.getElementById(id); div.style.display = div.style.display == "none" ? "block" : "none"; } function creditInput(id, amount) { var url = "my_campaigns?cat=ptc_normal"; var amount = $('input[name=amount"]').val(); $.ajax({ type:"GET", url:url, data:amount, cache:false, success:function(data){ document.location = "?cat=ptc_normal&allocate="+id+"&allocation_amount="+amount; } }); } </script>
<div id="ad_id"> <input type="text" id="amount_credit" name="amount"> <a onclick="creditInput(<?php echo $ad['id']; ?>)" href="javascript:void(0);">Pay</a> </div> <button onclick="togglediv(ad_id)">Toggle div</button>
Maybe you missed a quote in: 也许您错过了以下报价:
var amount = $('input[name="amount"]').val();
//-------------------------^----------------
First of all use this : 首先使用这个:
var amount = $('input[name="amount"]').val();
And then use object like syntax when passing data to server side : 然后在将数据传递到服务器端时使用类似语法的对象:
data : {
amount : amount
},
Check this, it will help you. 选中此项,将对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.