无法更新金额,因为我想输入
请帮我错了代码。我创建了一个ajax onClick函数,但信用额度不更新。问题是什么 ?无法更新金额,因为我想输入
var amount = $('input[name="amount"]').val();
//-------------------------^----------------
也许你错过了报价服务器端:
data : {
amount : amount
},
选中此项,它会帮助你。
一切正常,页面重新加载成功页面,但金额填写为空调用URL显示www.example.com/my_campaigns?cat=ptc_normal&allocate=5&allocation_amount= –
相同的问题不更新金额 –
猜你必须上传工作代码哪些说明你目前的问题。 在这一点上,我不能指出一个更好的解决方案。 – Edub
首先使用:
var amount = $('input[name="amount"]').val();
然后使用对象的语法传递数据时
<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) {
\t \t \t
var url = "my_campaigns?cat=ptc_normal";
var amount = $('input[name=amount"]').val();
\t
$.ajax({
type:"GET",
url:url,
data:amount,
cache:false,
success:function(data){
document.location = "?cat=ptc_normal&allocate="+id+"&allocation_amount="+amount;
}
});
}
\t \t \t \t \t \t \t \t
</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>
请勿更新网址www.example.com/my_campaigns?cat=ptc_normal&allocate=5&alloc ation_amount = –
同一问题不更新金额。 –
首先,'creditInput()'你错过了一个报价。它应该是'creditInput(“”)' –
@SuperCoolHandsomeGelBoy如果它不是? – Dherya