background preloader

AJAX

Facebook Twitter

/home/florian » JSONP avec jQuery. Catégorie Webdev : A propos du web, de son contenu, de ses outils...

/home/florian » JSONP avec jQuery

Vous êtes certainement déjà au courant mais on ne peut pas faire d’appel Ajax sur un autre domaine que celui où tourne le script pour des raisons de sécurité. Si vous avez quand même besoin de récupérer des données cross-domain, il existe une technique : le JSONP (ou JSON with padding). Un peu de théorie puis un cas pratique avec jQuery. Le JSONP Au lieu de récupérer du JSON, on va récupérer du JSONP, c’est-à-dire du JSON encapsulé dans un appel de fonction.

Les services web qui renvoient du JSON vous permettent en général de récupérer du JSONP en rajoutant le paramètre callback=foo dans l’url. Qu’est-ce qu’on en fait ? Au lieu de faire un appel avec l’objet XHR classique, vous allez simplement rajouter une balise <script> dans votre code qui va charger le code distant (oui, charger des scripts d’un autre domaine est autorisé). Easy Ajax with jQuery. This article was written in 2011 and remains one of our most popular posts.

Easy Ajax with jQuery

If you’re keen to learn more about jQuery, you may find this recent article on jQuery 1.9 of great interest. Ajax is changing web applications, giving them a responsiveness that’s unheard of beyond the desktop. But behind all the hype, there’s not much to Ajax — HTML, JavaScript, and XML are nothing new, and in this tutorial, I’ll show you how to simplify the process of adding Ajax to your application even further with the help of jQuery. What’s Ajax? You’ve probably heard about Ajax before, or at least used an Ajax-based application — Gmail, for instance. Unfortunately, in-depth tutorials on practical ways to enter the world of Ajax are few and far between. What’s jQuery? jQuery is another mature JavaScript library that offers some features that the others do not. Assumed Knowledge To complete this tutorial, you’ll need some basic JavaScript knowledge. jQuery 101 $("div.foo").append("Hello World!

"). Easy! Initiation à Ajax avec Jquery (partie 1) Qu’est-ce qu’ AJAX?

Initiation à Ajax avec Jquery (partie 1)

Ajax est apparu il y’a déjà quelques années et est un ensemble de technologies comme Javascript, l’objet XMLHTTPRequest, XML,… qui permettent d’envoyer des requêtes à votre serveur et de récupérer ses réponses sans raffraîchir votre page. On l’utilise souvent pour raffraichir des petits bouts de HTML, dans le but d’éviter des temps de chargement longs et des requêtes vers les serveurs trop lourdes à gérer. Et Qu’est-ce que Jquery? Jquery est un framework Javascript, c’est à dire une sorte de librairie de fonctions qui vous simplifient énormément la tâche.

Jquery est (avec d’autres…) devenu quasiment incontournable si l’on manipule un peu AJAX (on peut diviser par 5 le nombre de lignes de code). Ce premier tutorial va consister à supprimer une ligne dans une table SQL sans recharger la page. Etape 1 : Page principale Il faut tout d’abord afficher la liste des commentaires dans un tableau HTML dynamiquement avec PHP.

PHP Ajax Frameworks. From Ajax Patterns See also Multi-Language_Ajax_Frameworks and Ajax_Frameworks.

PHP Ajax Frameworks

Phery.js Phery.js is a tight implementation for DOM manipulation on the browser through AJAX directly from PHP, that is actively developed, since 2010, latest version in April 2013. Alternative to XAJAX The most advanced jQuery AJAX library for PHP. Using event delegation, every new element on the DOM can promptly send AJAX calls as easy as adding a data-remote.

Requires PHP 5.3.3+ and jQuery 1.8+ (works with jQuery 2.0) Cjax Cjax is an MVC (Model-View-Controller) oriented, lightweight (>100kb) ajax framework aimed at PHP applications/sites. Demos Lightweight > 100kb 100% Ajax Zero Configuration No page footprint No inline codes No Snippets or JavaScript needed No front-end JavaScript. 100% server side Insanely Fast Lives in harmony, not in competition with other frameworks Uses a combination of data services objects, xml/json Easy and Generic API Most APIs is just 1 line of code! Action Controller.