简体   繁体   中英

how to post array of values in jquery-ajax?

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM