Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AJAX Response : String or XML?

 
Romit Bose
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSON is the preferred method.

Eric
 
Romit Bose
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Romit Bose
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic