Re: JSON help



>
> How do I get the onchange thing on each of the
> selects to grab the selected values for all of the
> selects and pass it to the server using JSON. I
> can grab the data fine using the DOM (even
> FireFox's interesting implementation of the DOM
> isn't insurmountable really), but I can't figure
> out how to encode the data. I'm reading a lot
> about eval() but also seeing that some people feel
> that it is evil...?

Let me undestand exactly what you want.
Do you need to pass an object to the server ? Do you want to have all
the selected options back on the server? You need no JSON for this.
JSON stand for JavaScript Object Notation and it's often used by server
side scripts to deliver ready to use objects for javascript not vice
versa. Of course you can do it, but is too much overhead to deserialize
a json format when all you have to do is pass a comma separated list of
key:value pairs for instance.

Build something like this:
'select0:CSB1030C,select1:CSB1005C....
and you can split having the comma as separator thus obtaining the
key:value pairs and do a split on all these pairs having the colon as
separator and there you have them.

on the onchange event you can have a function that builds this string
and if you use XMLHttpRequest to pass it...use it in this function but
beware of launching multiple requests before the server response.

.



Relevant Pages

  • Re: JSON help
    ... selects to grab the selected values for all of the selects and pass it to the server using JSON. ... I can grab the data fine using the DOM, but I can't figure out how to encode the data. ... You have to serialise the data into a textual JSON representation, there isn't a built in way. ...
    (comp.lang.javascript)
  • JSON help
    ... selects to grab the selected values for all of the ... selects and pass it to the server using JSON. ... FireFox's interesting implementation of the DOM ...
    (comp.lang.javascript)
  • Re: Ajax/Javascript Query
    ... I have successfully sent a 'POST' to my server, built a response on the ... I originally intended this to be a JSON response, ... You use the built-in JSON functionality of modern (which is definitely ...
    (comp.lang.javascript)
  • RE: ASP.NET AJAX Date serialization and timezones
    ... I think this is unfortunately not possible if you're transferring a ... transferred and the client-side timezone information is not transferred to ... Nikhil Kothari has once discussed how the Date gets serialized in JSON: ... year/month/day parts separately to the server if you want to generate a ...
    (microsoft.public.dotnet.framework.aspnet)
  • Using AJAX/JSON and performance issues with eval()
    ... This is returned from the server and I use splitand loops to ... generate JS arrays / nested arrays at the client end. ... Now JSON seems the perfect on both fronts - it is lightweight and I ...
    (comp.lang.javascript)