I was wondering if its possible to pass data stored in a javascript array to the server using jQuery’s ajax function..
In the jQuery documentation it specifies:
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});
can “data” be set to an array? How would this work given it seems data is expecting key value pairs? I currently just hard code the values but I want it to be a more dynamic approach..my current code is:
jQuery.ajax({
url: "/createtrips/updateitin",
type: 'POST',
data: {place1: 'Sydney', place2: 'London'},
dataType: 'json',
});
I created an array like this:
then added to it like this:
(where
counteris an incremented counter variable)then assigned this to the
dataproperty of the ajax calland if I look at the XHR tab in firebug it appears those values get posted!