var type = new Array("Competency", "Gender", "Global" );
$.ajax({
url: "/Crew/Crew/GetDefinationType/",
type: "POST",
data: "{type:'" + type + "'}",
contentType: "application/json",
dataType: "json",
我没有看到数据数组
我该怎么做?
答案 0 :(得分:2)
var type = new Array("Competency", "Gender", "Global" );
// can also be var type = ["Competency", "Gender", "Global"];
$.ajax({
url: "/Crew/Crew/GetDefinationType/",
type: "POST",
data: {"type": type },
contentType: "application/json",
dataType: "json",
$ .ajax的数据属性不需要引号。
另一种方法是对数组进行字符串化
$.ajax({
url: "/Crew/Crew/GetDefinationType/",
type: "POST",
data: {"type": JSON.stringify(type) },
contentType: "application/json",
dataType: "json",
答案 1 :(得分:0)
var jsonObj = new Array("Competency", "Gender", "Global");
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: 'Home/getArray',
data: JSON.stringify({ "obj": jsonObj}),
async: false,
success: function (response) {
alert("");
},
error: function ()
{ console.log(''); }
});
这是快照