Chapter 8: Ajax Flashcards
What is AJAX?
A technique for loading data into part of a page without having to refresh the entire page
What is JSON?
Javascript Object Notation (Not javascript but string of javascript code)
What’s the common syntax for sending an XML Http Request?
xmlhttprequest
XMLHttpRequest
xmlHttpRequest
XMLHttpRequest
How to make an AJAX request
-create a new XMLHttpRequest.Then use the open and send methods. The open method takes 3 parameters: HTTP method, URL for page that handles request, Boolean to indicate if it should be asynchronous
var xhr = new XMLHttpRequest();
xhr. open(‘GET’, data/test.json, true);
xhr. send(‘search=arduino’);
What happens once the Browser has received and loaded data from the server
The online event will fire. The requests status will be checked and determine what side will run.
xhr.onload = function() { if (xhr.status === 200) { //do some code } }
What Data Formats can the serve send back?
HTML
XML
JSON