wood burning stoves
The moose likes HTML, CSS and JavaScript and the fly likes AJAX Response : String or XML? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "AJAX Response : String or XML?" Watch "AJAX Response : String or XML?" New topic

AJAX Response : String or XML?

Romit Bose
Ranch Hand

Joined: Oct 03, 2007
Posts: 50
hi all,
i am doing some work with AJAX where i need to pass some data from the client to the servlet and in return the server response will contain some data from a table.Now, the data may comprise of multiple rows, so, i need to decide upon how to pass the data. would it be better if i contructed a delimited string and passed it as a response, or should it be an XML that i must construct on the server side and parse back the data on the client? By better i mean performance and of course, the right way of doing it.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
JSON is the preferred method.

Romit Bose
Ranch Hand

Joined: Oct 03, 2007
Posts: 50
hi Eric,
JSON.... i must admit that i am really a greenhorn in javascript and i heard the term for the first time, so, can you please elaborate a little on that?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63862

JSON is a great way to pass data to JavaScript as it's much easier to digest than XML. Read here for more info.

If you are using a JavaScript library to do your Ajax for you (highly recommended) most have JSON interpretation already built in.
[ September 21, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Romit Bose
Ranch Hand

Joined: Oct 03, 2007
Posts: 50
Thanks Eric, Thanks Bear, for giving me the headstart at JSON. Now i am gonna learn more about it and implement it in my project.
Thank You once again!
I agree. Here's the link: http://aspose.com/file-tools
subject: AJAX Response : String or XML?
It's not a secret anymore!