简体   繁体   English

无法更新金额,因为我想输入

[英]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.

相关问题 我希望我的代码创建由输入行和列数的块组成的网格 - I want my code to create grid made of blocks with input amount of rows and columns 我想用输入字段更新一个数组,但是它创建了一个新的数组 - i want to update an array with an input field, but instead it creates a new one 我想将占位符属性添加到此DIV中的输入中,但是它没有可用来定位的唯一属性 - I want to add the placeholder attribute to the input within this DIV but it does not have a unique property that I could locate it with 我想通过输入类型按钮检查表单验证,而不是通过提交,可以在这有任何帮助吗? - i want to check form validation by input type button, not by submit, could any one help in this? 我想添加一个数组的用户输入 object 和 react useState(),当我发送它时它不更新问题? - I want to add user input object of an array with react useState(), when I send it it does not update the questions? 我想要一个带有隐藏数字的输入 - I want an input with a hidden digits 我想设置输入值 - I want to set input value 我想要输入类型的值 <input> 在JavaScript中 - i want value of input type <input> in javascript 我想限制 React js 中的分页数? - I want to limit amount of pagination numbers in React js? 我想为每个 oninput 的元素添加特定数量 - I want to add specific amount to a element on every oninput
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM