开发者

Send multiple fields with the same name via jQuery

how to send multiple fields with the same name via jQuery like this:

<input type="text" name="text[]" />
<input type="text" name="text[]" />
<input type="text" name="text[]" />

jQuery:

   function upload() {
    $.post('example.php', { text[]: Form开发者_StackOverflow中文版.text[].value },
      function(output) {
      $('#result').html(output).show();
      });
    }

upload.php:

text[$i] = $_POST['text'][$i];

thank you,

EDIT: correct my question.


I believe that serialize() will do the right thing and produce the appropriate form parameters for such a set of inputs.

$(function() {
   $('form').submit( function() {
       $.post( 'foo.php', $('[name^=bar]').serialize(), function(data) {
           alert(data);
       });
       return false;
   });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜