ajax传递数组到后台
ajax怎样传递一个数组到后台,数组格式为[{name:"aaa",age:"20"},{name:"bbb",age:"20"},{name:"ccc",age:"20...
ajax怎样传递一个数组到后台,数组格式为
[{name: "aaa", age: "20"}, {name: "bbb", age: "20"}, {name: "ccc", age: "20"}]
后台怎样接收,能给个例子最好,谢谢大神们~ 展开
[{name: "aaa", age: "20"}, {name: "bbb", age: "20"}, {name: "ccc", age: "20"}]
后台怎样接收,能给个例子最好,谢谢大神们~ 展开
1个回答
展开全部
下载个jquery.js
用.ajax函数,参数类型为json,后台用json_decode解码就成了数组了
$("#btn2").click(function() {
$.ajax({
type: "POST",
contentType: "application/json",
url: "server.php",
data: "{name: "aaa", age: "20"}, {name: "bbb", age: "20"}, {name: "ccc", age: "20"}
",
dataType: 'json',
success: function(result) {
alert(result.d);
}
});
});
用.ajax函数,参数类型为json,后台用json_decode解码就成了数组了
$("#btn2").click(function() {
$.ajax({
type: "POST",
contentType: "application/json",
url: "server.php",
data: "{name: "aaa", age: "20"}, {name: "bbb", age: "20"}, {name: "ccc", age: "20"}
",
dataType: 'json',
success: function(result) {
alert(result.d);
}
});
});
追问
后台是java,能给个具体点的后台例子吗?谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询