I have the following code:
var ids = [];
for (var i = 0, row; row = table.rows[i]; i++) {
if (parseInt(row.cells[0].innerHTML || 0) > 0 ) {
ids.push(row.cells[0].innerHTML);
}
}
var submit_data = {name: vname, users:ids};
$.ajax({
url: "/cgi-bin/add_users",
dataType: "json",
data: submit_data,
success: function(data) {
$("#").html();
}
});
on the server side when i check the type of the variable on the ids, it's a string...All the data is there. But it has a bunch of spaces in between each record.
Any tips on how I get the back end to recognize my array as an array?
Thanks.
EDIT 1
Here's the server side code. All I'm doing right now is logging:
if FORM.name then
u.log(tostring(type(FORM.users)))
u.log(FORM.users)
end
The logs show:
Wed May 13 12:25:40 2015 - string
Wed May 13 12:25:40 2015 - 232
233
Wed May 13 12:25:40 2015 - connect to sysdb
The first two entries you see in the log is what is produced by the code in question. I would like an array that looks like [232,233] or even a json array like {1:232,2:233}
Found this post: Pass array to ajax request in $.ajax()
Trying out the suggestions there for now.
EDIT 2
Here's what the query string looks like:
http://testserver/cgi-bin/add_users?name=test&users%5B%5D=231&users%5B%5D=232