Learning About AJAX
The following is a guest post by Adam Waxman and originally appeared on his blog. Adam is currently a student at The Flatiron School. You can follow him on Twitter here.
So What is AJAX?
What does an AJAX request look like?
At a high level an AJAX request consists of the URL you a making a request to, and then corresponding settings to handle the response. Below are a few of the more popular callbacks that make up the settings:
success: what to do if the URL request is successful
error: what to do if the URL request is unsuccessful
timeout: how long to allow the URL request to run before an error message pops up
beforeSend: runs before the AJAX request, good place to put a spinner
complete: runs after both success and error, good place to stop a spinner
Example 1: makes a request to ‘index.html’ and then inserts the response into the item in the DOM that has a class called “hello-world”
Example 5 demonstrates some of the callback settings. In this AJAX request, if the response is not successfully made it will stop the request after 3 seconds (3000 milliseconds). It also demonstrates common code for adding a loading animation while the request is being made.
Disclaimer: The information in this blog is current as of 22 July 2013. Current policies, offerings, procedures, and programs may differ. For up-to-date information visit FlatironSchool.com.
Posted by Flatiron School / July 22, 2013
Learn to Code Python: Free Lesson for Beginners
How To Get The Most Out Of Student Advising
The Flatiron School Student Advising team is here to support our students through all of the ups and downs that come with pursuing a bootcamp.