Agility, Java programming, New technologies and more…
  • rss
  • Home
  • Management
  • Agile Programming
  • Technology
  • Linux
  • Event
  • Android app
  • Contact
  • About the author
  • English
  • Francais

jQuery & Ajax

Fabian Piau | Thursday September 22nd, 2011 - 06:05 PM
  • Print
  • Twitter
  • LinkedIn
  • Facebook
  • Pocket

 Version française disponible

Ajax

Ajax logo

Appeared in 2005, Ajax (Asynchronous JavaScript and XML) is a group of existing technologies, including HTML, JavaScript and XML. With Ajax, web applications are able to make quick, incremental updates to the user interface without reloading the entire browser page. Thus, it allows Web pages to be more interactive and behave like local applications, which are also known as RIA applications (Rich Internet Applications). The term “Asynchronous” means that the JavaScript allows the page to continue to be processed and will handle the reply if and when it arrives. In synchronous mode, the browser is “frozen” while the request is processing.


jQuery

jQuery logo

Initiated in 2006, the jQuery project is an open source JavaScript library which has become very popular. It allows the development of JavaScript quickly and concisely, as its slogan “Write less, do more” says ! jQuery handles events, performs animations, includes CSS selectors, adds Ajax interactions to Web pages… In addition, many plugins are available and the library is cross-browser.


Ajax with jQuery

There are several ways to do Ajax with jQuery.


$.get(url, data, callback, type)

$.get() is a general way to make GET requests. It handles the response of many formats including XML, Html, Text, Script and Json.

	function add_elements_table(elementIds) {
		$.get( 'demoajax.php', 
				{	
					'cmd': 'addElements', 
					'elementSelecteds': elementIds
				}, 
				function (data) { refresh_table() });
	}



$.post(url, data, callback, type)

$.post() does exactly the same job as $.get(), except for the fact that it makes a POST request instead.


$.ajax(settings)

$.get() and $.post() are high-level abstractions that are often easy to understand and use. If you need maximum control over your requests, check out the $.ajax() function. You can specify ajax options (e.g. error callbacks, browser cache). $.ajax() argument is a set of key/value pairs that initialize and configure the Ajax request.

	function add_elements_table(elementIds) {
		$.ajax({ url : 'demoajax.php', 
				data : {	
					'cmd': 'addElements', 
					'elementSelecteds': elementIds
				},
				cache : false,
				success : function (data) { refresh_table() }});
	}


Ajax caching issues with Internet Explorer !

I have been working on a project that involves using jQuery and Ajax. I have using the $.get() method to handle simple calls. The JavaScript was working great on Firefox, Chrome and also on Internet Explorer 6.
However, I realized that on IE7, 8 and 9, some strange and random behaviors happen.
After some research, I find out that it was a caching issue. The first time, the Ajax call is properly treated. But, the second time, the server has not been requested and the data from the very first Ajax call was returned…
Now, I recommend the use of $.ajax() with the “cache: false” option.

Related posts

Progress barDate progress bar using JQuery Clean browser cacheCSS and Javascript files play hide and seek in browsers’ cache
Comments
No Comments »
Categories
Agile programming
Tags
ajax, jquery, caching issue ie
Comments rss Comments rss
Page 1 of 11
Download CarmaBlog App

RSS feeds

  • RSS feed RSS - Posts
  • RSS feed RSS - Comments

Most viewed posts

  • Changing the language in Firefox - 115,579 views
  • Using Google Forms / Drive / Docs to create an online survey - 63,166 views
  • FAQ – Online survey with Google Forms / Drive / Docs - 52,403 views
  • Customizing Gnome 3 (Shell) - 30,017 views
  • The meaning of URL, URI, URN - 17,251 views
  • Java EE & CDI vs. Spring - 15,442 views
  • Open Street Map, better map than Google Maps? - 14,648 views
  • Comparing NoSQL: Couchbase & MongoDB - 14,082 views
  • Firefox Nightly, Aurora, Beta, Desktop, Mobile, ESR & Co. - 13,087 views
  • API, REST, JSON, XML, HTTP, URI… What language do you speak? - 12,718 views

Recent Comments

  • Pauline on FAQ – Online survey with Google Forms / Drive / DocsMerci Fabian, mais le but étant que nos clients pu…
  • Fabian Piau on FAQ – Online survey with Google Forms / Drive / DocsProbablement mais ces options sont en général paya…
  • Pauline on FAQ – Online survey with Google Forms / Drive / DocsBonjour Fabian, Merci de votre retour, oui j'avais…
  • Fabian Piau on FAQ – Online survey with Google Forms / Drive / DocsBonjour Pauline, ce n'est pas possible de créer un…
  • Pauline on FAQ – Online survey with Google Forms / Drive / DocsBonjour, Je suis en train de créer un Google Forms…

Recent posts

  • How to write a blog post? At least my way! - 3 months and 2 weeks ago
  • Bot Attacks: You are not alone… - 1 year and 11 months ago
  • Flagger – Monitor your Canary deployments with Grafana - 2 years and 8 months ago
  • Flagger – Canary deployments on Kubernetes - 2 years and 10 months ago
  • Flagger – Get Started with Istio and Kubernetes - 2 years and 10 months ago
  • Expedia CoderDojo in London - 3 years and 7 months ago
  • Volunteering at Devoxx4Kids - 3 years and 10 months ago
  • A Java 11 migration successful story - 4 years and 2 months ago
  • Tips to make your WordPress website secure - 4 years and 5 months ago
  • Devoxx UK 2018 – Day 2 - 4 years and 9 months ago
  • Devoxx UK 2018 – Day 1 - 4 years and 9 months ago
  • Wise, Revolut and Monzo, a small revolution for travelers and expats - 5 years and 1 month ago
  • Autocomplete for Git - 5 years and 10 months ago
  • Swagger, the automated API documentation - 6 years and 2 weeks ago
  • Microservices architecture – Best practices - 6 years and 5 months ago
Buy me a coffee

Language

  • Français
  • English

Follow me!

Follow me on Linkedin
Follow me on Twitter
Follow me on Stackoverflow
Follow me on Github
Follow me on Rss
Link to my Contact

Email subscription

Enter your email address to receive notifications of new posts.

Tags

.net agile agility android bash best practices blog cache cloud computing conference continuous integration css developer devoxx docker eclipse extreme programming firefox flagger google helm hibernate istio java job jug kubernetes london mobile computing overview performance plugin programmer script security sharing society spring tdd test tool ubuntu windows wordpress

Links

  • Blog Ippon Technologies
  • Blog Publicis Sapient
  • Blog Zenika
  • Classpert
  • CommitStrip
  • Coursera
  • Le Touilleur Express
  • Les Cast Codeurs Podcast
  • OCTO talks !
  • The Twelve-Factor App

Categories

  • Event (15)
  • Linux (3)
  • Management (8)
  • Agile programming (29)
  • Technology (45)

Archives

  • December 2022 (1)
  • April 2021 (1)
  • June 2020 (1)
  • May 2020 (2)
  • July 2019 (1)
  • May 2019 (1)
  • December 2018 (1)
  • October 2018 (1)
  • June 2018 (1)
  • May 2018 (1)
  • January 2018 (1)
  • May 2017 (1)
  • March 2017 (1)
  • October 2016 (1)
  • April 2016 (2)
  • March 2016 (1)
  • November 2015 (1)
  • May 2015 (1)
  • February 2015 (1)
  • December 2014 (1)
  • November 2014 (1)
  • September 2014 (2)
  • August 2014 (1)
  • July 2014 (2)
  • June 2014 (1)
  • April 2014 (1)
  • March 2014 (1)
  • February 2014 (2)
  • January 2014 (1)
  • December 2013 (1)
  • November 2013 (1)
  • October 2013 (3)
  • September 2013 (5)
  • July 2013 (1)
  • June 2013 (1)
  • May 2013 (1)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (1)
  • January 2013 (2)
  • December 2012 (2)
  • October 2012 (1)
  • September 2012 (1)
  • July 2012 (1)
  • May 2012 (1)
  • April 2012 (1)
  • March 2012 (1)
  • February 2012 (1)
  • January 2012 (2)
  • December 2011 (1)
  • November 2011 (2)
  • October 2011 (2)
  • September 2011 (1)
  • July 2011 (1)
  • June 2011 (2)
  • April 2011 (1)
  • March 2011 (1)
  • February 2011 (1)
  • January 2011 (2)
  • November 2010 (2)
  • September 2010 (1)
  • August 2010 (1)
  • July 2010 (1)
  • June 2010 (1)
  • May 2010 (1)
  • April 2010 (1)
  • March 2010 (1)
  • February 2010 (1)
  • December 2009 (1)
  • November 2009 (1)
  • October 2009 (2)
  • September 2009 (2)
  • August 2009 (3)
  • July 2009 (1)
  • June 2009 (2)
Follow me on Twitter
Follow me on Linkedin
Follow me on Stackoverflow
Follow me on Rss
Link to my Contact
Follow me on Github
 
Fabian Piau | © 2009 - 2023
All Rights Reserved | Top ↑