Reputation: 29797
I have an array of hashes in Javascript, which I need to send as a parameter in a jQuery.get() request. I've tried this:
$.get('../notes/notes_temp_path',{temp_param:notes_array}, function(data) {
console.log("done");
});
but the server doesn't get the temp_param
parameter. What do I need to do? Thanks for reading.
EDIT:
If I do
for (index in notes_array) {
console.log(notes_array[index]);
}
console.log(window.JSON.stringify(notes_array));
I get
[ ]
note_name "note1"
[ ]
note_name "note2"
[[],[]]
The server receives this as well:
"temp_param"=>"[[],[]]"
Upvotes: 0
Views: 292
Reputation: 236092
Best practice would be to json'ize
the array.
$.get('../notes/notes_temp_path',{temp_param: window.JSON.stringify(notes_array)}, function(data) {
console.log("done");
});
whatever serverside language you use, you need to parse
that JSON-string and use it further.
Upvotes: 1