Minor API Change in 1.0.2

Posted on by

I forgot to mention in the 1.0.2 release notes, the other day, that there was a minor API change. This was a mistake, as we should’ve held off on making an API change until the next major release (jQuery 1.1).

As summarized by Steven Wittens, here is the premise behind the change:

In jQuery 1.0.2, the first argument to the ‘success’ callback has been changed to return the actual data rather than the XMLHttpRequest object. Use the ‘dataType’ argument to $.ajax() to control how the data is returned. Note that jQuery can now parse XML, JSON and JavaScript for you this way.

jQuery 1.0.1

$.ajax( {
  success: function (xmlhttp) {
    var data = $.httpData( xmlhttp );
    // 'data' holds the response data from the server

jQuery 1.0.2

$.ajax( {
  success: function (data) {
    // 'data' holds the response data from the server

Thanks, Steven, for the synopsis – and sorry, everyone, for the inconvenience!

8 thoughts on “Minor API Change in 1.0.2

  1. Wow that’s great!
    The other day I was wondering why it returned the ‘XMLHttpRequest object’ because the response data would have made more sense. :)

  2. Pingback: KeBlog :: Kej’s weblog » jQuery 1.0.2

  3. Oh man! I suffered with this!
    I gave up and returned to the precedent release.
    Now happy to see what happened :) Thanks!

  4. I am really sorry for posting this here but I could not find a way to post something to this Bug Tracker and I may care for jQuery but I am not the mailing list guy, so I’d liek to just report this: while the .ready() works fine in the online version of my site under Opera 9 (latest build), on my local version (running on apache) it fails badly when a page is reloaded but works for the first time the page is accessed. The weird thing is that it returns no erros in the Error Console.Note that this only happens in Opera. Maybe someone could look at it?
    Thank you in advance.

  5. Well I noticed there was a change. This particularily affects the progressive enhancement article, as often if using json as the type, it’s difficult to always get the server response exactly what you want it before you lock into json. Sometimes i’ll dump a variable out in non json format. Then everything broke. I modified jq-latest for this:.

    httpData: function(r,type) {
    var ct = r.getResponseHeader(“content-type”);
    var data = !type && ct && ct.indexOf(“xml”) >= 0;
    data = type == “xml” || data ? r.responseXML : r.responseText;

    // If the type is “script”, eval it
    if ( type == “script” ) eval.call( window, data );

    // Get the JavaScript object, if JSON is used.

    if (type == “json”) {
    alert(“Data returned: “+data);
    try {
    eval( “data = ” + data );
    catch(e) {
    alert(“Error on JSON Evaluation:”+e.message);

    //if ( type == “json” ) eval( “data = ” + data );

    return data;


  6. Andrey Skvortsov on said:

    That’s nice but must be alternative-I want not string but genuine XmlHttp object,particularly if I work with xml data in some cases.How about $(“?”,xml.responseXml)?What if I need to transform data or store data in xml document format(for future reference using $() function)?Reparsing?
    How I can get back previous behavior?Or we all work with strings from now?XmlHttp object contains much more information than data itself and it must be accessible IMHO(just in case for more advanced development).