var url = "/MyApp/pspace/filter";
var data = JSON.stringify(myData);
$.post(
url,
data,
function(response, textStatus, jqXHR) {
console.log("response: " + response);
},
"json"
);
In reality, response should be a json string.
In Chrome, response is a string that I can parse with $.parseJSON().
In Firefox, response is an XMLDocument (with a parse error), unless I use dataType: "text". Why?
If you are setting “json” as your response type jQuery should parse it into an object for you automatically. If you forgot to tell jQuery what type of response to expect different browsers will treat it differently.
The solution is to make sure you specify your response type as “json” and then of course to make sure the data that is being returned is an actual JSON string.