logo       

[jQuery] $.ajax API change 1.0.2?: msg#01167

lang.javascript.jquery

Subject: [jQuery] $.ajax API change 1.0.2?

It seems that the 'success' callback of $.ajax was changed to accept
as its first argument the actual parsed data rather than the xmlHttp
object, in 1.0.2? This behaviour broke several Drupal features when I
upgraded it to jQuery 1.0.2...

We should really avoid such API changes in the future, or bump up the
middle version digit instead. In jQuery, the line between what is a
private function and what is an API call is indeed blurred (so
guaranteeing compatibility across versions for everything is near-
impossible), but it would be nice if this stuff was at least
documented. I looked around and can't seem to find any mention of
this on the 1.0.2 release notes or on this mailing list.

In Drupal, we document all API changes on a page with before/after
examples. If you build such a page when you commit changes to the
repository, it's not that much work.

Here's a snippet to document this change (if I got it right):

== $.ajax callback changed ==
In jQuery 1.0.2, the first argument to the 'succes' 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) {
// do stuff with xmlhttp.responseText
}
);
// jQuery 1.0.2
$.ajax( {
success: function (data) {
// do stuff with data
}
);


Steven Wittens


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise