- Send data to be stored in the DB (no response)
- Refresh an information panel on the screen (e.g. HTML response)
- Refresh a different area of the screen (e.g. HTML response)
Currently, I am handling this by firing off 3 AJAX requests. This is not ideal, as there is a limit to the number of consecutive requests a browser can have open, and it also starts up three sessions on server-side. I would prefer the AJAX request to send over a package of data using get/post and have the server-side receive the package, parse it out, and form up it's own package to send back. This package would be an object containing multiple packets of HTML and one packet of Javascript. Delivery would be kind of like a warehouse receiving an order for multiple items - the shipment won't be made until all the requested items are bundled together, ready to be shipped off.
All this server-side stuff is fine, I have most of it in place with the current setup, but I'm wondering what the best option would be to send the data back to the client? As far as I can see, there are two options available - JSON and XML. Is anyone aware if there is preferred data format, and whether there are issues with either one that needs to be considered? Does encoding come into it at all? What happens if one of the HTML packets contains a special JSON/XML character/phrase, such as } or </end_of_my_xml_element>.
Also, once the package is received by the client, the scripts will need to be evaluated. I'm guessing the eval() function is the way to go, but have never used the function myself, and am aware there is a field of thought that eval is "bad". Can anyone shed light on whether this is a good/necessary use of the eval function? To me, it looks like it is.

New Topic/Question
Reply


MultiQuote






|