Here is my array:
arr[0]='A';
arr[1]='B';
....
I tried to post it this way:
$.post('data.php',arr,function() {
});
But fails to work as expected.
Here is my array:
arr[0]='A';
arr[1]='B';
....
I tried to post it this way:
$.post('data.php',arr,function() {
});
But fails to work as expected.
You can't post an array. What you need is a hash:
parameters = { "Param1" : "A", "Param2" : "B" };
Choose a suitable name and convert your array to a hash:
hash = {};
$.each(arr, function(i, elem) {
hash["Param" + i] = elem;
});
From the manual:
data (Optional) Map, String
Key/value pairs or the return value of the .serialize() function that will be sent to the server.
And from the examples in the manual:
$.post("test.php", { 'choices[]': ["Jon", "Susan"] });
Therefore:
$.post("test.php", { 'arr[]': arr });