Possible Duplicate:
Serializing to JSON in jQuery
I want to send an array as an Ajax request:
info[0] = 'hi';
info[1] = 'hello';
$.ajax({
type: "POST",
url: "index.php",
success: function(msg){
$('.answer').html(msg);
}
});
How can I do this?
NOTE: Doesn't work on newer versions of jQuery.
Since you are using jQuery please use it's seralize function to serialize data and then pass it into the data parameter of ajax call:
Just use the JSON.stringify method and pass it through as the "data" parameter for the $.ajax function, like follows:
You just need to make sure you include the JSON2.js file in your page...