File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

AJAX Response : String or XML?

Romit Bose
Ranch Hand

Joined: Oct 03, 2007
Posts: 50
hi all,
greetings,
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.
Thanks!
Eric Pascarello
author
Rancher

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

Eric
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
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Romit Bose
Ranch Hand

Joined: Oct 03, 2007
Posts: 50
Hi,
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?