Send JSON data with jQuery

Total Post:3

Points:21
AJAX  JQuery 
 502  View(s)
Ratings:
Rate this:

I want to send data as Json format but why this code returning Name=Mindstick City=Allahabad 

var arr = {Name:'Mindstick', City:Allahabad};

$.ajax(
   {
        url: "Ajax.ashx",
        type: "POST",
        data: arr,
        dataType: 'json',
        async: false,
        success: function(msg) {
            alert(msg);
        }
    }
);

can any helpme

  1. Post:2

    Points:14
    Re: Send JSON data with jQuery

    Try this code

    var arr = {Name:'Mindstick', City:Allahabad};
    $.ajax({
        url: 'Ajax.ashx',
        type: 'POST',
        data: JSON.stringify(arr),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        async: false,
        success: function(msg) {
            alert(msg);
        }
    });

    You have not specified contentType

Answer