Should I use XML or text, JavaScript, or HTML as a return type?

It depends. Clearly the X in AJAX stands for XML, but several AJAX proponents are quick to point out that nothing in AJAX, per se, precludes using other types of payload, such as, JavaScript, HTML, or plain text. 
XML - Web Services and AJAX seem made for one another. You can use client-side API for downloading and parsing the XML content from RESTful Web Services. (However be mindful with some SOAP based Web Services architectures the payloads can get quite large and complex, and therefore may be inappropriate with AJAX techniques.) 
Plain Text - In this case server-generated text may be injected into a document or evaluated by client-side logic. 
JavaScript - This is an extension to the plain text case with the exception that a server-side component passes a fragment of JavaScript including JavaScript object declarations. Using the JavaScript eval () function you can then create the objects on the client. JavaScript Object Notation (JSON), which is a JavaScript object based data exchange specification, relies on this technique. 
HTML - Injecting server-generated HTML fragments directly into a document is generally a very effective AJAX technique. However, it can be complicated keeping the server-side component in sync with what is displayed on the client. Mashup is a popular term for creating a completely new web application by combining the content from disparate Web Services and other online API. 

Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*