Reputation: 31
var type = new Array("Competency", "Gender", "Global" );
$.ajax({
url: "/Crew/Crew/GetDefinationType/",
type: "POST",
data: "{type:'" + type + "'}",
contentType: "application/json",
dataType: "json",
I do not see the array of data
How can I do that?
Upvotes: 2
Views: 43
Reputation: 21
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(''); }
});
Here is snap shot
https://i.sstatic.net/tMRGA.png
Upvotes: 0
Reputation: 18566
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",
No quotes are required for the data attribute of $.ajax.
Another way, is to stringify the array
$.ajax({
url: "/Crew/Crew/GetDefinationType/",
type: "POST",
data: {"type": JSON.stringify(type) },
contentType: "application/json",
dataType: "json",
Upvotes: 2