I tried to send an array as part of an ajax request like this:
var query = [];
// in between I add some values to \'query\'
$.ajax({
url: \"MyServlet\",
Just try to send the data as name/value pair (which is expected). Like
var query = ["data1","data2"];
// in between I add some values to 'query'
$.ajax({
url: "MyServlet",
data: {'query' : query},
success: function(noOfResults) {
alert(noOfResults);
}
});
}
You should get the data at server side like this
query => Array ( [0] => data1 [1] => data2 )
As per the jQuery documentation for data setting of jQuery.Ajax() method
If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting