Parsing AJAX Responses with JavaScript and the innerHTML Property
(Page 1 of 4 )
If you work with AJAX and have ever wondered which approach is best to use when parsing the responses triggered by a web server after performing an HTTP request, this article series is for you. Composed of three parts, it will lay out your options and the most efficient approaches. This article, the first part of the series, focuses on the "responseText" property and the "innerHTML" property.
If you're a web developer who has already tasted the power of AJAX, then you're familiar with the buzzwords associated with this technology and the correct utilization of all of its methods and properties. Indeed, developing AJAX-driven web applications on a frequent basis will give you a strong sense of confidence in mastering the pillars of this web development area, such as working with HTTP requester objects, handling synchronous and asynchronous HTTP requests, and logically processing the range of responses sent by a web server and triggered by a JavaScript application.
However, while acquiring a decent background in how to work with AJAX is actually a no-brainer process that can be tackled with minor hassles, the truth is that eventually you may have some gaps on this topic that naturally must be properly filled in. But what do I really mean by filling in some gaps? Well, if you found yourself scratching your head trying to figure out what AJAX property is better to use to parse a specific web server response, then you may need to take a look at some approaches to how to achieve this as painlessly as possible.
AJAX offers only two primary properties to parse all of the HTTP responses sent by a web server; these are the "responseText" and "responseXML." Even so, there are certain situations during the development of an AJAX application that can be quite challenging to tackle, particularly if you have serious doubts about how to process the outputs of JavaScript-based HTTP requests.
Therefore, in this three-part series of articles, I'll be showing you by means of numerous code samples, different approaches that you may want to use to parse all of the responses triggered by a web server after performing an AJAX HTTP request. These tutorials will cover both text and XML-based responses, in this way providing you with a friendly guide on how to process AJAX requests with minor hassles.
Speaking more specifically, the first installment of the series will walk you through working with the popular "responseText" property, so get ready to sharpen your existing skills for processing text-based responses with AJAX. Let's begin this educational journey now!
Next: Working with HTTP XML Request objects >>
More JavaScript Articles
More By Alejandro Gervasio