posts - 48, comments - 13, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

ajax post 数组

Posted on 2010-07-14 11:46 董锐 阅读(735) 评论(0)  编辑  收藏

I know how to send by jquery post method $.post("test.php", { name: "John", time: "2pm" } );

but what if my form field name is array

<input type=text name="n1[]" id="n1[]" value='12345">   <input type=text name="n1[]" id="n1[]" value="14454">  

how to send these 2 field value send to url by jquery post method?

 

You can pass in an array as a value in the object:

{name: 'John', 'nl[]': ['12345', '14454']}  

(This is documented at ajax but also works for post.)

 

var fields = $(":input").serializeArray();      $.post("test.php",fields);

from:http://stackoverflow.com/questions/1656267/how-to-send-multi-field-value-by-jquery-post


只有注册用户登录后才能发表评论。


网站导航: