2
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

enter image description here

How can I do that?

enter image description here

0

2 Answers 2

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",

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",
Sign up to request clarification or add additional context in comments.

1 Comment

hello mohammedrias but is not working I see the value of the variable is null
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(''); }
    });

Here is snap shot

https://i.sstatic.net/tMRGA.png

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.