简体   繁体   中英

Easiest way to pass a javascript array or its values to a servlet using jQuery's ajax() function

I have a Javascript array. I want to pass it's data to a servlet using the ajax() method of jQuery.

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.

Maybe I should be converting the JavaScript array to a JSON Object and sending that to the server ??

I am stumped on this one.

try this :

$.post('your page', {data : yourjavascriptarray}, function() {

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM