Reputation: 583
How to post array of values in 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?
Upvotes: 0
Views: 1237
Reputation: 1038710
You could use the .serialize()
method on the containing form:
$.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
.
Upvotes: 5