jQuery 1.0.4
Another fantastic release of jQuery is ready for your consumption. This release includes a number of bug fixes (as usual) along with some much-needed improvements to jQuery’s Ajax functionality.
As always, if you have any questions or concerns with new release, please feel free to discuss it on the jQuery Mailing List. If you think you’ve spotted a bug, please add it to the bug tracker.
So, without further ado, here’s jQuery 1.0.4:
Download
- Compressed JavaScript (Recommended Download!)
- Uncompressed JavaScript
- 1.0.4 Documentation
- 1.0.4 Test Suite
- Full Release (jQuery, Test Suite, Documentation)
- Build Files (Compile your own version of jQuery 1.0.4)
Changes and Features
- Tons of bug fixes (Full List)
- Extensions to $.ajax(): $.ajax accepts additional options: beforeSend, async and processData; returns XMLHttpRequest to allow manual aborting of requests, see docs for details.
Example: Add extra headers to an Ajax request using beforeSend
$.ajax({ type: "POST", url: "/files/add/", beforeSend: function(xhr) { xhr.setRequestHeader( "Content-type", "text/plain" ); }, data: "This is the contents of my text file." });
Example: Perform a synchronous Ajax request.
// Get the HTML of a web page and save it // to a variable (the browser will freeze until the // entire request is completed). var html = $.ajax({ type: "GET", url: "test.html", async: false }).responseText; // Add the HTML into the page $("#list").html( html );
Example: Sending a JavaScript object using processData.
// The data to send to the server var params = { name: "John", city: "Boston" }; // Send the data, but have it be converted into // a format the server can understand (w/ processData) $.ajax({ type: "POST", url: "/user/add/", data: params, processData: true });
Example: Aborting an Ajax request after a specific delay in time.
// Perform a simple Ajax request var req = $.ajax({ type: "GET", url: "/user/list/", success: function(data) { // Do something with the data... // Then remove the request. req = null; } }); // Wait for 5 seconds setTimeout(function(){ // If the request is still running, abort it. if ( req ) req.abort(); }, 5000);
- AJAX module: The public $.ajax API is now used internally (for $.get/$.post etc.); loading scripts works now much more reliably in all browsers (with the exception of Safari, which is a work in progress).
- New global Ajax handler: ajaxSend – called before an Ajax request is sent.
Example: Add extra headers to all Ajax requests using the ajaxSend event.
$(document).ajaxSend(function(xhr){ xhr.setRequestHeader("X-Web-Request", "MySite.com"); });
- Extensions to global Ajax handlers: ajaxSend, ajaxSuccess, ajaxError and ajaxComplete get XMLHttpRequest and settings passed as arguments.
Example: Prevent any POST requests that are sending too much data.
$(document).ajaxSend(function(xhr,options){ if ( options.type == "POST" && options.data.length > 1024 ) xhr.abort(); });
Example: Show a special message for requests submitted using an Ajax POST.
$("#dataSent").ajaxSend(function(xhr,options){ if ( options.type == "POST" ) $(this).show(); });
- Extensions to event handling: pageX and pageY are available in all browsers now. (IE does not provide native pageX/Y).
Example: Have a tooltip follow a user’s mouse around the page.
$(document).mousemove(function(e){ $("#mousetip").css({ top: e.pageY + "px", left: e.pageX + "px" }); });
- Improved docs: $(String) method has now two separate descriptions, one for selecting elements, one for creating html on-the-fly.
- FX module: Most inline styles added by animations are now removed when the animation is complete, eg. height style when animating height (exception: display styles).
You rock John (and jQuery team :) )
I forgot to mention: As with most of the 1.0.x releases, much of this release was due to the hard work of Jörn Zaefferer.
I plan on doing a post, soon, doing a who’s who of jQuery. There’s many people who help out right now, in many ways (coding, testing, documentation, plugins, design, web site, marketing) and they all need to be thanked.
Many thanks, I like the pageX, pageY example the most!
Pingback: sorgalla.com - Updates
Problem with IE and the test suite:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Avant Browser; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
core module: not(String) (1, 1, 2)
– not(‘selector’)
– not(‘selector, selector’) expected: [object],[object],[object],[object], result: [object],[object],[object],[object],[object]
ajax module: $.ajax – beforeSend (1, 0, 1)
– check return value, should be the custom header sent
Tests completed in 12703 milliseconds.
2 tests of 288 failed.
Great job.
Thanks for all team.
Pingback: jQuery: 1.0.4 is out. Time to upgrade!!! « Rip’s Domain
Pingback: jQuery 1.0.4 | Scriptorama
Pingback: BorkWeb » jQuery 1.0.4 Released
Please note that the processData example above is not correct. It should be:
Good catch, Mike! I fixed the example to be correct.
Pingback: 15 Days Of jQuery : New Version of jQuery Released
Problem with FF2.0 and the test suite:
# core module: not(String) (1, 1, 2)
1. not(‘selector’)
2. not(‘selector, selector’) expected: [object HTMLParagraphElement],[object HTMLParagraphElement],[object HTMLParagraphElement],[object HTMLParagraphElement], result: [object HTMLParagraphElement],[object HTMLParagraphElement],[object HTMLParagraphElement],[object HTMLParagraphElement],[object HTMLParagraphElement]
@Giel: That error is expected. That’s a feature that we’re working to implement in jQuery (but isn’t in yet). So we built the test case before, so that we have something to work towards :-)
John and the team. You’re really really great. jQuery genius!!!
:)
jQuery.setAuto(…) is not present in this new version.
interface/ifx.js needs it, do you have some suggest?
Thanks :-)
Pingback: jQuery mejora el Ajax con la 1.0.4 - aNieto2K
Pingback: BlogsYa » jQuery mejora el Ajax con la 1.0.4
jQuery.setAuto(…) is not present in this new version.
interface/ifx.js requires it and it worries me as well.
I manually moved some piece of code from 1.0.3, but…
var options = { ‘dataType’ : ‘json’ } or var options = { ‘dataType’ : ‘html’ }
$.ajax( options );
Not works, it sends me XML data back
Whatever – Thank You! jQuery is wonderful, and it’s better and better each day.
Pingback: bassistance.de » jQuery related news: 1.0.4 release, people, tooltip
Pingback: jQuery updates: 1.0.4, documentation, and people