Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing AJAX Response objects

Status
Not open for further replies.

jcale4

Programmer
Aug 31, 2004
63
US
Hello,

I have a simple form where a user inputs an account number into an input, on submit it uses Ajax to request information about that account from a database using a server-side ASP page. I am able to take the responseText and assign it to the innerHTML of an element in the page. My question is, how can i parse that responseText (maybe using XML instead) and assign each peice of the response to a different element. (so, i want to populate the account name, address, city, etc. in different labels on the page).

Thanks!
 
Hello jcale,

Since you are exploring the data exchange format , I would recommend using JSON instead of XML for its simplicity, and yes you will have to using some form of data exchaneg format unless you want to write your down yoru own complex parser .It all depends on the the complexity of the reponse and the dynamic nature of it.

Thanks.
 
I agree 100% with bean1234, JSON is straight Javascript code and is much easier to parse than XML (not quite so much DOM manipulation)


try here for a start:


<.
 
I agree, from what I've read, JSON appears to be quicker than XML also. What I dont understand is how i return a name/value pair from an ASP page. All I know how to do from ASP is a response.write() on the page and the recordset gets returned as a String along with all the other HTML tags from the page. Is there a specific format I need to return the data in so that i can parse it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top