jQuery: The Write Less, Do More JavaScript Library

Blog » jQuery 1.0.4

Posted December 12th, 2006 by John Resig

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

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).

26 Responses to “jQuery 1.0.4”

  1. Nate Cavanaugh Says:

    You rock John (and jQuery team :) )

  2. John Resig Says:

    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.

  3. Nilesh Patel Says:

    Many thanks, I like the pageX, pageY example the most!

  4. Weblogger.ch » Blog Archive » jQuery Says:

    […] Bonne nouvelle, la version 1.04 de la librarie vient de sortir avec un tonne de bugs corrigés et quelques nouvelles fonctionnalités. Consultez l’annonce pour plus détails directement sur le blog de jQuery. […]

  5. sorgalla.com - Updates Says:

    […] Additionally, jCarousel is delivered with the brand new jQuery 1.0.4. […]

  6. Henrik Says:

    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.

  7. DeyV Says:

    Great job.
    Thanks for all team.

  8. jQuery: 1.0.4 is out. Time to upgrade!!! « Rip’s Domain Says:

    […] Yesterday saw another fantastic release of jQuery to 1.0.4. The are numerous bug fixes in this release, too many to go over. […]

  9. jQuery 1.0.4 | Scriptorama Says:

    […] John Resig en de rest van ‘t jQuery-team hebben een verse release voor ons JavaScript-gemak: jQuery 1.0.4. De nadruk ligt vooral op Ajax-functionaliteit. De nieuwe $.ajax()-uitbreidingen geven je o.a. rechtstreeks toegang tot ‘t gebruikte XMLHttpRequest object. Hierdoor kun je bijvoorbeeld headers inpluggen of requests afbreken. Daarnaast zijn event.pageX en event.pageY nu in alle browsers beschikbaar, ook in Internet Explorer. Nog niet bekend met jQuery? Eerder gaven we een korte inleiding. Voor prima voorbeelden kun je terecht op learningjquery.com. […]

  10. BorkWeb » jQuery 1.0.4 Released Says:

    […] John Resig over at jQuery has announced the release of jQuery 1.0.4 to the public! As usual, there are bug fixes…plus a bit more. His focus for this patch was adding improvements to jQuery’s Ajax functionality. Below is a list of all the updates: […]

  11. Mike Says:

    Please note that the processData example above is not correct. It should be:

    // The data to send to the server
    var params = {
      name: "John",
      city: "Boston"
    };
    
    $.ajax({
      type: "POST",
      url: "/user/add/",
      data: params,
      processData: true
    });
  12. John Resig Says:

    Good catch, Mike! I fixed the example to be correct.

  13. 15 Days Of jQuery : New Version of jQuery Released Says:

    […] Just announced today, version 1.0.4 of jQuery was released. […]

  14. Riddle's Miniblog Says:

    jQuery 1.0.4.

    Poprawki, bugfiksy, Ajax. Czyli nowa wersja mojej ukochanej biblioteki JavaScript. Mappet już na niej śmiga (może zacznie działać na Safari?).

  15. Giel Berkers Says:

    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]

  16. John Resig Says:

    @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 :-)

  17. Bakyt Niyazov Says:

    John and the team. You’re really really great. jQuery genius!!!

    :)

  18. Diego Says:

    jQuery.setAuto(…) is not present in this new version.
    interface/ifx.js needs it, do you have some suggest?

    Thanks :-)

  19. jQuery mejora el Ajax con la 1.0.4 - aNieto2K Says:

    […] En la lucha de los frameworks de Javascript, jQuery ha dado hoy un paso importante con una nueva versión y las modificaciones añadidas al objeto Ajax. […]

  20. JQuery 1.0.4 un ajax mejorado at FX Site Says:

    […] El módulo Ajax, pasa a ser $.ajax() en lugar de $.get()/$.post(), que los usará internamente dependiendo del parametro type que definamos.Además han añadido un handler nuevo destinado a controlar los eventos Ajax, de esta forma dispondremos de métodos ajaxSend, ajaxSuccess, ajaxError y ajaxComplete para trabajar con él. Y muchas más… […]

  21. BlogsYa » jQuery mejora el Ajax con la 1.0.4 Says:

    […] En la lucha de los frameworks de Javascript, jQuery ha dado hoy un paso importante con una nueva versión y las modificaciones añadidas al objeto Ajax. […]

  22. Xander Says:

    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…

  23. Излезе jQuery 1.0.4 at Мързеливец и Co. Says:

    […] Ето тук може да видите повече за промените в новата версия. […]

  24. Xander Says:

    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.

  25. bassistance.de » jQuery related news: 1.0.4 release, people, tooltip Says:

    […] jQuery 1.0.4 was released on 12th Dezember, featuring tons of bug fixes and several improvements to API documentation in general and with focus on the AJAX module. Details can be found in John’s release entry. […]

  26. jQuery updates: 1.0.4, documentation, and people Says:

    […] A new 1.0.4 release focused on updates to the Ajax functionality: […]