1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Introduction to Ajax

8. responseText and responseXML

clr gif

In the last tutorial we looked at how we can determine whether the response is XML or plain text. The reason why we must know the answer to this (either by knowing what the server side script is set up to return or by testing the content type in our code) is that the response is returned in one of two different fields depending on which of these two formats it is that is being used.

The following code fragment illustrates these two fields by substituting alerts to display the appropriate field into the code from our last tutorial where we tested the content type.

if (cType == 'text/xml') {
} else if (cType == 'text/plain') {
} else {
alert('unknown content type');
See More About
Explore JavaScript
By Category
    javascriptJavaScriptcomputeTechb950eefb2a063b7b4e00399d305537ef3a00038e0c006b2ahttp://javascript.about.comod526F6F7412274terminatedStephen Chapmanjavascriptguide3Og00025zNIP11970-01-0110/od/index.htm0526F6F741approved/od
  1. About.com
  2. Tech
  3. JavaScript

©2015 About.com. All rights reserved.