Web Programming - Week 8 Flashcards
What is AJAX
Asynchronous Javascript and XML - A set of web development techniques
AJAX Bullet points
Enables web browser to send and recieve data in the background
Makes it possible to update the page without reloading
How to create an object for AJAX
var httprequest = new XMLHttpRequest();
How to initialise a request
httprequest.open(method, url, async)
Methods of http requests
GET and POST
How to send a http request
httprequest.send();
How to send a request with form data
httprequest.setRequestHeader(“Content type”, url)
AJAX status responses
200 - OK
403 - Forbidden
404 - Page not found
Choosing which function will manage a response of a request
httprequest.onreadystatechange = function;
jQuery AJAX methods
load() - loads data directly in html
$.get()
$.post() - large data
$.ajax() - most configurable
AJAX load syntax
$(selector).load(URL,callback);
What is the callback argument
The name of a function to be executed after a load method
AJAX method syntax
$.ajax({name:value, name:value…})