Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Voices That Matter

How To Use AJAX

  • Print
  • + Share This
Like this article? We recommend

Making the Request

Now that your request object has been created, you're ready to make a request to the server. Create a reference for an event handler to listen for onreadystatechange. The event handler method will then react when the state changes. We'll write this method as soon as we finish writing the request. Open the connection to GET or POST a custom URL, which in this case is the content.xml, and set a Boolean defining whether you want the call to be asynchronous.

It's time to send the request. In the example, I use null because we're using GET; to use POST, you would send a query string with this method:

request.onreadystatechange = onResponse;"GET". url, true);
  • + Share This
  • 🔖 Save To Your Account