I know this is probably going to be a nice easy answer, but I've been searching all over for a nice simple and clean solution and have yet to find one. Let me elaborate...
Can't I do something like...
I haven't found anything like this anywhere and I'm just wondering what the easiest way is to do this? Or if I should be doing something different to get my array to the servlet...
The most natural way for server code to get array data (especially if using Servlets) is the traditional query parameter format.
That said, JSON server libraries are getting more popular (I use Stringtree) so if you did want to pass a JSON string back to the server, I'm sure you can find a way to digest it. I'm just not so sure it's the best (aka simplest) approach.
You could simply iterate over the array with $.each() to format a query string of:
In the servlet:
(If the value will consist of anything other than alphanumerics be sure to URI-encode the values.)
Joined: Nov 19, 2007
I do get the selected orders from the current page of my grid but the array could also have saved values from other pages in the grid that are not a part of the DOM at the point when I want to send the request to the server... so a purely DOM solution won't work. I'll have to probably just format like you suggested...
Thanks for the help. I still wish there was an easy way in jquery to create JSON from an array, or any object for that matter, that can be passed to the server. String tree is pretty good at handling JSON and I think that it would be a nice solution especially for simpler objects like arrays.
I found that one too, but I haven't tried it. Doesn't he say something about not using it with 1.2? One of those places did when I was poking around...I have tossed around the idea of giving that plugin a whirl..... eeee