[英]Easiest way to pass a javascript array or its values to a servlet using jQuery's ajax() function
I have a Javascript array. 我有一个Javascript数组。 I want to pass it's data to a servlet using the ajax() method of jQuery.
我想使用jQuery的ajax()方法将其数据传递到servlet。
What is the easiest way to do this. 什么是最简单的方法。 The index values ie the i in array[i] are not in order, they are numbers that have meaning themselves, hence I cannot simply loop through and create a GET queryString, or so I believe.
索引值,即array [i]中的i不按顺序排列,它们是具有自身含义的数字,因此,我无法简单地循环遍历并创建GET queryString,或者我相信。
Maybe I should be converting the JavaScript array to a JSON Object and sending that to the server ?? 也许我应该将JavaScript数组转换为JSON对象,然后将其发送到服务器?
I am stumped on this one. 我为此感到困惑。
try this : 尝试这个 :
$.post('your page', {data : yourjavascriptarray}, function() {
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.