![](/img/trans.png)
[英]I want my code to create grid made of blocks with input amount of rows and columns
[英]could not update amount as i want to input
请为我提供错误代码。 我已经创建了一个ajax onClick函数,但是信用额没有更新。 问题是什么 ?
<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>
也许您错过了以下报价:
var amount = $('input[name="amount"]').val();
//-------------------------^----------------
首先使用这个:
var amount = $('input[name="amount"]').val();
然后在将数据传递到服务器端时使用类似语法的对象:
data : {
amount : amount
},
选中此项,将对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.