Php jquery:使用$.post更新变量数量的值
我想在ajax中更新可变数量的项。我所拥有的是Php jquery:使用$.post更新变量数量的值,php,jquery,Php,Jquery,我想在ajax中更新可变数量的项。我所拥有的是 <input name="cart[qty][25]" id="25" value="10" size="4" title="Qty" class="input-text qty"> 但是我想要美元的。发布类似的东西 jQuery(".update-cart").on('click',function(){ jQuery(".cart-item").each(function(){ var id = jQuery(this)
<input name="cart[qty][25]" id="25" value="10" size="4" title="Qty" class="input-text qty">
但是我想要美元的。发布类似的东西
jQuery(".update-cart").on('click',function(){
jQuery(".cart-item").each(function(){
var id = jQuery(this).attr('id');
var qty = jQuery(this).val();
//What should i do here and on my php file ?
});
});
您可以尝试Jquery序列化方法 更新:
jQuery(".update-cart").on('click',function(){
jQuery(".cart-item").each(function(){
if(jQuery(this).hasClass('qty'))
{
var id = jQuery(this).attr('id');
var qty = jQuery(this).val();
}
//What should i do here and on my php file ?
});
});
或
您在同一页上有相同的id…?是的,假设页面上有10个字段是的,我知道,但这会发送所有字段。我需要的字段有一个数量类。
jQuery(".update-cart").on('click',function(){
jQuery(".cart-item").each(function(){
if(jQuery(this).hasClass('qty'))
{
var id = jQuery(this).attr('id');
var qty = jQuery(this).val();
}
//What should i do here and on my php file ?
});
});
jQuery(".update-cart").on('click',function(){
alert($('.qty').serialize());
});