topical media & game development
#javascript-code-05-post.js / js
// Create the request object
var xml = new XMLHttpRequest();
// Open the asynchronous POST request
xml.open("POST", "/some/url.cgi", true);
// Set the content-type header, so that the server
// knows how to interpret the data that we're sending
xml.setRequestHeader(
"Content-Type", "application/x-www-form-urlencoded");
// Make sure the browser sends the right content length of the serialized data –
// Mozilla-based browsers sometimes have trouble with this
if ( xml.overrideMimeType )
xml.setRequestHeader("Connection", "close");
// Establish the connection to the server and send the serialized data
xml.send( serialize( data ) );
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.