[英]How do I send an array of hashes as a parameter in a jQuery.get() request?
我在Javascript中有一个哈希数组,我需要将其作为参数发送到jQuery.get()请求中。 我已经试过了:
$.get('../notes/notes_temp_path',{temp_param:notes_array}, function(data) {
console.log("done");
});
但是服务器没有获得temp_param
参数。 我需要做什么? 谢谢阅读。
编辑:
如果我做
for (index in notes_array) {
console.log(notes_array[index]);
}
console.log(window.JSON.stringify(notes_array));
我懂了
[ ]
note_name "note1"
[ ]
note_name "note2"
[[],[]]
服务器也收到此消息:
"temp_param"=>"[[],[]]"
最佳实践是对数组进行json'ize
。
$.get('../notes/notes_temp_path',{temp_param: window.JSON.stringify(notes_array)}, function(data) {
console.log("done");
});
无论您使用哪种服务器端语言,都需要parse
该JSON字符串并进一步使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.