Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home AJAX XML
 

XML Advantage in Ajax

 

Ajax would be nothing without XML. After all, the “x” in the acronym stands for XML which means it is a very important aspect in the Ajax based application. There are those that are not even Ajax that uses XML.


For example, JavaScript could still use XML as its data format especially when developers needed to improve their application in terms of availability to other websites. Since it’s considered as the universal data format, developers have been using XML to ensure that their application will work as planned.


But even with the known ease in using XML, there are still challenges developers have to go through in building an application through XML. Challenges such as browser incompatibility (especially in IE) and security are still the main concern of developers. However, even these challenges should not stop any developer from adopting XML because of an advantage that could be given by XML.


There are four data return types a developer could use in JavaScript and Ajax. They can use HTML, Text, JSON and XML as their return. HTML is regarded as lightweight but very limited in terms of adaptability to JavaScript. This is also true with text but even lighter. JSON should work perfectly with JavaScript since it’s the data return specified to work with JavaScript but it’s still struggling with browser compatibility.


XML on the other hand has features that could be found in JSON, adaptable to different browsers but could be as lightweight as HTML. The main reason why XML is adopted by developers is that when XML is returned to the client side after the process, it doesn’t come back only as raw data to be displayed in the client side. XML comes back with additional functions that could trigger more functionality in the client side.


As already indicated, the main challenge of developers in working with XML is browser incompatibility particularly with Internet Explorer (IE). But this could be handled with two commands. The first command goes this way:


    request.overrideMimeType('text/xml')


This function should be added before you retrieve the processed data. This function will override the restrictions in different browsers especially in IE. By calling to override any types of data format, it will be regarded by any browser as generic data.


The next code is a lot easier but could be costly in some situations:


    "Content-type: text/xml"


This code is added in the header of the online application. You may have noticed that the content type is written blatantly to specify that the application would have to deal with XML from that point. This header will practically limit which data format that should be considered by developers. If you are working with additional return types, you might not be able to work with them properly since they will be labeled as XML.


But even with these restrictions in XML, this form of data still provides the best data return for an Ajax based and JavaScript application. Through smart coding to deal with browser incompatibilities, developers should be able to build an effective application.



Read Next: Building Ajax Applications Using SXML



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links