ajax如何传一个数组到后台
展开全部
下载个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);
}
});
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询