Fixes #7229 and #5803
[jquery.git] / src / ajax.js
index f3252eb..915bbaa 100644 (file)
@@ -208,6 +208,12 @@ jQuery.extend({
                        s.data = jQuery.param( s.data, s.traditional );
                }
 
+               // If the jsonpCallback has been set, we can assume that dataType is jsonp
+               // Ticket #5803
+               if ( s.jsonpCallback ) {
+                 s.dataType = "jsonp";
+               }
+
                // Handle JSONP Parameter Callbacks
                if ( s.dataType === "jsonp" ) {
                        if ( type === "GET" ) {
@@ -250,14 +256,14 @@ jQuery.extend({
                                                delete window[ jsonp ];
                                        } catch( jsonpError ) {}
                                }
+
+                               data = tmp;
+                               jQuery.handleSuccess( s, xhr, status, data );
+                               jQuery.handleComplete( s, xhr, status, data );
                                
                                if ( head ) {
                                        head.removeChild( script );
                                }
-                               
-                               data = tmp;
-                               jQuery.ajax.handleSuccess( s, xhr, status, data );
-                               jQuery.ajax.handleComplete( s, xhr, status, data );
                        };
                }