Skip to Content
Head Rush Ajax
book

Head Rush Ajax

by Brett McLaughlin
March 2006
Beginner to intermediate
448 pages
13h 33m
English
O'Reilly Media, Inc.
Content preview from Head Rush Ajax
360
Chapter 6
Hey, I bet it’s just as easy to send an XML
request as it is to receive an XML response.
It turns out that you’ve got to do a good bit of
work to send XML... in fact, quite a bit more
work than it took to receive XML from the
server. Most of the time, the effort you’ll have
to put into sending XML just isn’t worth it.
First, you’ll need to send the XML in a POST
request...
Well, there’s a little more to it...
Sure, that makes sense. Because XML can
get pretty long, and there’s that maximum
URL length on GET requests, right?
It doesn’t take a lot of data before an XML
document gets pretty long. You’ll denitely
need to use a POST request. Additionally,
you’ll need to let the server know that you’re
sending it XML, not name/value pairs.
That’s right.
Even the short XML
response from the
Boards server took up
almost 200 characters!
That’s easy, too. I bet we can use a different
Content-Type request header, right?
You can use the setRequestHeader()
method on your request object to tell the
server that you’re sending it XML, like this:
You’ve really got this stuff down!
request.setRequestHeader(“Content-Type”, “text/xml”);
This tells the server that the content type of the
incoming message is XML, in text format.
sending xml requests
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally

Publisher Resources

ISBN: 0596102259Errata PageSupplemental Content