[英]how to post array of values in jquery-ajax?
How to post array of values in jquery-ajax? 如何在jquery-ajax中发布值数组?
<input type='text' name='mynameinputs[]'>
<textarea id='mydescription' name='mydescriptioninputs[]'></textarea>
<input type='text' name='myquantityinputs[]'>
<input type='text' name='mynameinputs[]'>
<textarea id='mydescription' name='mydescriptioninputs[]'></textarea>
<input type='text' name='myquantityinputs[]'>
<input type='text' name='mynameinputs[]'>
<textarea id='mydescription' name='mydescriptioninputs[]'></textarea>
<input type='text' name='myquantityinputs[]'>
$.post(url,{''}, function(data){}
How to get the values of each and post it to a php file? 如何获取每个的值并将其发布到php文件?
You could use the .serialize()
method on the containing form: 您可以在包含表单上使用
.serialize()
方法:
$.ajax({
url: 'foo.php',
type: 'POST',
data: $('#if_of_the_form').serialize(),
success: function(result) {
}
});
$('#if_of_the_form').serialize()
will format the values as if it was a normal form submit - using application/x-www-form-urlencoded
. $('#if_of_the_form').serialize()
会将值格式化为正常形式的提交-使用application/x-www-form-urlencoded
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.