AJAX - The Complete Reference

(avery) #1

4 Data Formats


L


ike any software application, the raw material consumed or created by an Ajax
application is data. Given the “X” in the Ajax acronym, the assumption might be that
this data is in the form of XML data, but that isn’t necessarily the case. Looking at Ajax
applications in the wild, it is common to see a variety of data formats including plain text,
comma-separated value (CSV) data values, HTML fragments, raw JavaScript statements,
JavaScript Object Notation (JSON) values, and of course, XML using both public- and
developer-defined schemas. Less commonly, you might see data in more esoteric text formats
such as YAML, and occasionally even binary style formats like base64 data might be used.
The choice of data format shouldn’t be selected on a developer’s whim, as there are obvious
pros and cons of the various formats. In this chapter, we explore the various data formats
you might consider in an Ajax application as well as the design decisions behind the
selection of each.

Ajax and Character Sets


International readers are likely painfully aware that far too often content encoding in Web
pages is not indicated properly.

115


CHAPTER


http://www.ebooks.org.in

Free download pdf