]> source.dussan.org Git - jquery.git/commitdiff
Fixes #7229 and #5803 58/head 59/head 65/head 66/head 67/head 70/head 71/head
authorrwldrn <waldron.rick@gmail.com>
Sun, 24 Oct 2010 16:18:33 +0000 (12:18 -0400)
committerrwldrn <waldron.rick@gmail.com>
Sun, 24 Oct 2010 16:18:33 +0000 (12:18 -0400)
src/ajax.js
src/event.js
test/unit/ajax.js
test/unit/event.js

index a40e223e76dd599790c08e18c086a11feb268922..915bbaa3e73d987799437bf2ee293031f515ea54 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" ) {
index fb5a3ef8cc6fa0bd4f7ec79f201c093540111979..d491ae8a116998447ff54daff392f0fc2be31ba8 100644 (file)
@@ -32,6 +32,9 @@ jQuery.event = {
 
                if ( handler === false ) {
                        handler = returnFalse;
+               } else if ( !handler ) {
+                 // Fixes bug #7229. Fix recommended by jdalton
+                 return;
                }
 
                var handleObjIn, handleObj;
index 5704d73e0deddbb912e51d8988fe9b01b0462455..14c6218264a74362bacea9be2f388e0a1441bced 100644 (file)
@@ -799,6 +799,21 @@ test("jQuery.ajax() - JSONP, Local", function() {
                        plus();
                }
        });
+       
+  // Supports Ticket #5803     
+       jQuery.ajax({
+               url: "data/jsonp.php",
+               jsonpCallback: "jsonpResults",
+               success: function(data){
+                       ok( data.data, "JSON results returned without dataType:jsonp when jsonpCallback is defined" );
+                       plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, custom callback name)" );
+                       plus();
+               }
+       });             
+       
 });
 
 test("JSONP - Custom JSONP Callback", function() {
index f3d314884f952acf7aac4bff3ce90485db650f01..5efa0ec51de44941de5d7956d8f4ea05e5a11c8a 100644 (file)
@@ -1,5 +1,25 @@
 module("event");
 
+test("null or undefined handler", function() {
+       expect(2);
+  // Supports Fixes bug #7229
+  try {
+  
+    jQuery("#firstp").click(null);
+  
+    ok(true, "Passing a null handler will not throw an exception");
+
+  } catch (e) {}  
+
+  try {
+  
+    jQuery("#firstp").click(undefined);
+  
+    ok(true, "Passing an undefined handler will not throw an exception");
+
+  } catch (e) {}  
+});
+
 test("bind(), with data", function() {
        expect(3);
        var handler = function(event) {