AJAX Flashcards
What is AJAX? why do we use it?
AJAX is Asynchronous JavaScript And XML. AJAX is not a programming language.It uses a combination of a browser built-in XMLHttpRequest object, to request data from a web serverJavascript and HTML DOM, to display or use the dataWe use AJAX to make aysnchronous calls to a web server. It allows the client browser to avoid waiting for all data to arrive before allowing the user to act once more
What are the benefits of using AJAX?
AJAX improves the speed, performance and usability of a web application
Explain why it is important that AJAX is asynchronous
So that the page continues to be processed and handled replies if and when it arrives
List the steps to sending an AJAX request
- Make a XMLHttpRequest object: XMLHttpRequest request = new XMLHttpRequest()
- Use the object and call open method: request.open(method,url,async)
- Use the object and call send method: request.send() —used for get, for post use send(string) method
List the different ready states of the XmlHttpRequest object
Unsent (0), Opened (1), Headers_Recieved (2), Loading (3), Done (4)
How does the fetch API differ from the XHR object?
Fetch is a new native JavaScript API. Fetch allows us to make network requests similar to XMLHttpRequest. Fetch is an improvement over the XMLHttpRequest API. The main difference between the two is that Fetch uses Promises, hence avoiding callback hell.