jQuery a simplifié l'écriture d'AJAX plus besoin de XMLHttpRequest et ses probl`emes Specify the JavaScript function without () nor parameters
XMLHttpRequest fires an event when data arrives A callback to which you can attach a handler function CSC443: Web Programming 17 A typical Ajax request
AJAX – JavaScript event fires • calls user defined JavaScript function – Client browser makes a request using XMLHttpRequest
requests for data PHP file interacts with database, return JSON data JSON data Request JavaScript (or jQuery) function when an event is triggered
jQuery provides the following basic useful functions for AJAX: }) done (the call back function, for when the ajax call succeeds )
AJAX Asynchronous Javascript And XML AJAX A lot of hype Set up the URL; Open the connection; Set a callback method; Send the request
Ajax – Sending data You can make calls to the server from your web browser using $ ajax; You can provide data in a hash list: $('#add') click(function(){
example18-2 htm (continuation ) startJS() is invoked when the button is clicked AJAX – connect to server, send request function startJS() {
jQuery is a JavaScript library; Basic knowledge of HTML, CSS, lot of the complicated things from JavaScript, like Ajax calls and DOM mainpulation
function (aka jQuery() function) returns A JavaScript object containing Ajax with jQuery(2) If we need all control over the Ajax request we can get: