Serializing to JSON in JavaScript
Posted: 10 Jan 2015, 08:11
I need to serialize an object to JSON in JavaScript. Is there a "standard" way to do this?
I have an array defined something like this:
And I need to convert this into a json string to pass to $.ajax() like this:
I have an array defined something like this:
Code: Select all
var countries = [];
countries[0] = 'ga';
countries[1] = 'cd';
...
Code: Select all
$.ajax({
type: "POST",
url: "Concessions.aspx/GetConcessions",
data: "{'countries': ['ga','cd']}",
...