I would like to ask
1. How to return XML or JSON via AJAX Request
2. How can I digest the returned XML or JSON on the JS File that called the AJAX Request
I am using jquery to perform AJAX Request, particularly this way:
// this is the call back function to handle the response
I am using it on my site to perform basic tasks, such as checking if username or email is still available while a user is registering. So far so good, coz I am using only basic things about
but I have another page on my site, where an admin (this is an admin area) can input the id of the user, then all information of that user, such as email, username, firstname, lastname, age, etc.... will be retrieved from the db and be displayed on that page.
Now I dont want the result back as a very long string, I want the result inside some form of a data structure, and that is either XML or JSON
Please do help me on this. Also
3. not so important question, which one is better? XML or JSON?
I know this is like comparing an apple to an orange, but I want to know the basic difference of the 2, such as, which is much easier to learn, much cleaner syntax, etc.. etc..
Please do provide sample codes,