[PDF] AJAX with jQuery



Previous PDF Next PDF







Apprendre le Javascript - pdfbibcom

Pour apprendre et exploiter le Javascript, il vous faut : 1 un browser qui reconnaît le Javascript 2 une solide connaissance du Html 3 un simple éditeur de texte 4 1 Un browser compatible Javascript Uniquement Netscape et Microsoft vous proposent des navigateurs Javascript "enabled" Pour Microsoft à partir



Claude Bernard University Lyon 1

˘ˇˆ ˙˝˛˚ ˜ "#$ &˝ ˙ ’ () ***+, &˝ ˙ -˝ "# /"# 01,,+ 2ˆ 345 1 ˝(& ’ ˝(& ’ 01,,+ /"#6˚ ’ ˘ ((˝ ˘"˝ ˝ ˛ ˚ 7˘˝ ˘ˇ˚ ˇ



AJAX with jQuery

Writing objects in Javascript: the JSON format JSON = JavaScript Object Notation An object has several properties Each property is a string Each property has a value, which may be a string, a number, a boolean (true or false), the empty value (null), an object or a table An object is written between braces var myObject = {"lastName":"Gambette",



three - RIP Tutorial

en d’autres termes, pour les nuls La bibliothèque fournit des rendus de type canvas, svg, CSS3D et WebGL Versions Version Changelog Date de sortie R85 Lien 2017-04-25 R84 Lien 2017-01-19 R83 Lien 2016-12-15 R82 Lien 2016-12-15 R81 Lien 2016-09-16 R80 Lien 2016-08-23 R79 Lien 2016-07-14 R78 Lien 2016-06-20 Examples Installation ou configuration



Processin - Sinitier à la programmation créative

La figure 1 1 montre les cinq versions disponibles : une version pour le système Mac OS X, deux versions pour le système Linux et deux versions pour le système d’ex-ploitation Windows Figure 1 1 Les versions de Processing disponibles Avant d’accéder aux différents liens de téléchargement,le site propose à ceux qui le



Professional Xmpp Programming With Javascript And Jquery [PDF]

# Book Professional Xmpp Programming With Javascript And Jquery # Uploaded By Kyotaro Nishimura, professional xmpp programming with javascript and jquery is a book about developing web applications using the xmpp protocol written by jack moffitt and published by wrox the book explains the xmpp protocol and its many uses as



MongoDB : Base de donnée orientée documents

Utilisation de la console Javascript (1) Lancement du serveur et de la console Le serveur se lance à lʹaide de la commande mongod exe Lʹinterpréteur de commandes Javascript correspond à la commande mongo exe Connexion ou création dʹune base de donnée use Insertion dʹun document dans une collection



Introduction au NoSQL

alors effectuer beaucoup de jointures pour reconsolider l'ensemble de l'information) C'est le problème posé par le décisionnel 2 Au delà des bases de données relationnelles : Data warehouse, XML et NoSQL a) Problème de l'agrégat et développement des data warehouses Fondamental Le modèle relationnel est peu performant pour les agrégats

[PDF] cours javascript debutant

[PDF] cours allemand kehl

[PDF] cours d'allemand ? strasbourg

[PDF] université populaire kehl

[PDF] alphabet arabe traduit en francais pdf

[PDF] alphabet coranique

[PDF] alphabet arabe français gratuit

[PDF] apprendre alphabet arabe audio

[PDF] telecharger assimil espagnol gratuit

[PDF] telecharger assimil espagnol mp3 gratuit

[PDF] assimil le nouvel espagnol sans peine mp3+pdf

[PDF] assimil espagnol perfectionnement pdf

[PDF] le nouvel espagnol sans peine pdf

[PDF] assimil espagnol audio download

[PDF] assimil espagnol pdf mp3

Licence CRRW - IUT de Marne-la-Vallée

2019-02-14

AJAX with jQuery

Philippe Gambette

• Lectures by Jean-Loup Guillaume • Advanced web programming lectures by Thierry Hamon • jQuery : écrivez moins pour faire plus !, by tit_toinou • jQuery, Le guide complet, by Guillaume Allain and Timothy Stubbs • Javascript & Ajax pour les nuls, by Andy Harris • jQuery documentation : http://api.jquery.com/ Sources used 2

Introduction à AJAX

AJAX = software architecture to update a webpage on the client side (in the browser) using information from the server side without reloading the page asynchronous = we are not waiting for the result of previous queries to launch the next ones and the next Javascript instructions.

Introduction à AJAX

AJAX = software architecture to update a webpage on the client side (in the browser) using information from the server side without reloading the page asynchronous = we are not waiting for the result of previous queries to launch the next ones and the next Javascript instructions.

Advantages of AJAX:

• deal with information streams in real time • allow collaborative web tools • optimize the loading time of a webpage and the bandwidth

Loading content

To insert some content into an object:

• Simpler than with AJAX functions • Possible to load only part of the file (even if all the file is retrieved, then parsed to extract only the required part) // version without parameters: // retrieves file.html, puts its content into a div $("div").load("file.html"); // version with parameters: calls file.php // providing name=philippe (POST) $("div#content").load("file.php", {"name":"philippe"}); // version retrieving only the object with id #myId $("div").load('file.php #myId'); http://api.jquery.com/load/

With GET and POST

// retrieve the file file.php // then execute a function // GET: parameters in the URL: $.get( "http://website.com/file.php", {"name":"philippe"}, function(data){ console.log(data); // POST : parameters in the message header // (useful for special characters, big size, etc.) $.post( "http://website.com/file.php", {"name":"philippe"}, function(data){ console.log(data);

Writing objects in Javascript: the JSON format

JSON = JavaScript Object Notation

An object has several properties. Each property is a string. Each property has a value, which may be a string, a number, a boolean (true or false), the empty value (null), an object or a table.

An object is written between braces.

var myObject = {"lastName":"Gambette", "firstName":"Philippe", "birth":1984, "height":1.81}; Same as the objects in the .css(...) function of jQuery! To get or set the value of one property, use the dot:

MyObject.firstName="Phil";

console.log("First name: "+myObject.firstName);

Or use square brackets:

MyObject["firstName"]="Phil";

console.log("First name: "+myObject["firstName"]);

Writing objects in Javascript: the JSON format

A table contains several values, which may be strings, numbers, booleans, empty values, objects or tables.

A table is written between square brackets.

var names = ["Berthet", "Gambette", "Jottreau"]; To get or set the value of one property, use the square brackets, starting at number 0 for the first cell of the table. names[0]="Philippe Gambette"; console.log("PHP+jQuery: "+names[0]+", "+names[1]);

A more complex example

var data = {"film":[{"attributs": {"id":"Q21855700"},"titre":"Demain","realisation": {"personne": {"personne": [{"attributs": data.film[0].realisation.personne[0].prenom + " " + //displays "Cyril Dion" data["fil"+"m"][0]["realisation"]["personne"][1].prenom + " " + //affiche "Mélanie Laurent" How to use Javascript objects retrieved by the AJAX query If the page http://website.com/file.php?id=9 contains the following JSON code: {"lastName":"Gambette", "firstName":"Philippe", "birth":1984, "height":1.81}

You can get these values in your jQuery code:

$.get( "http://website.com/file.php?id=9", function(data){ console.log("Last name: "+data["lastName"]+ ", first name:"+data.firstName);

AJAX functions

// Function to call when a request completes .ajaxComplete() // Function to call to handle errors in the end .ajaxError() // Fonction to call before any request is sent .ajaxStart() // Function to call before one request is sent .ajaxSend() // Function to call when every request is finished // Ajax sont terminées .ajaxStop() // Function to call when a request finishes // successfully .ajaxSuccess()

Constraints of asynchronous execution

AJAX events are not related with one special request: → it is necessary to remember the requests to find out where a given request came from $('.log').ajaxComplete(function(e, xhr, settings) { if (settings.url == 'ajax/test.html') { $(this).text('ok.');

Testing AJAX functions

Jquery Code :

$('.trigger').click(function(){ $('.result').load('fichier.json');

HTML code:

Trigger

Testing AJAX functions: alternatives

[request].done(function(data, textStatus, jqXHR){ }) : function executed when the AJAX request is successful [request].fail(function(jqXHR, textStatus, errorThrown){ }) : function executed when the AJAX request is not successful [request].always(function(jqXHR, textStatus){ }) : function executed in any case after done or fail. jqXHR: Javascript object used for the AJAX request textStatus: string describing the staus of the request (success, timeout, error, notmodified, parsererror) errorThrown : the error which was sent if there is any data : le data sent by the server

Retrieving JSON files or Javascript code

// Loading and extracting information from a // JSON file $.getJSON( "file.json", {id:1}, function(users) { alert(users[0].name); // Loading and executing a Javascript code $.getScript( "script.js", function() {

The generic AJAX function

Functions get, post, getJavascript, getJSON, etc. are specific cases of the ajax function: $.ajax({ async: false, type: "POST", url: "test.html", data: "nom=JL", success: function(msg){ alert( "Data Saved: " + msg );}

Generic AJAX function

$.ajax({ async: false, type: "POST", url: "test.html", data: "nom=JL", success: function(msg){ alert( "Data Saved: " + msg );} success equivalent to done error equivalent to fail complete equivalent to alwaysquotesdbs_dbs4.pdfusesText_8