diff --git a/src/ajax/load.js b/src/ajax/load.js
index cc2a71958..337064673 100644
--- a/src/ajax/load.js
+++ b/src/ajax/load.js
@@ -25,7 +25,7 @@ jQuery.fn.load = function( url, params, callback ) {
off = url.indexOf(" ");
if ( off >= 0 ) {
- selector = url.slice( off, url.length );
+ selector = jQuery.trim( url.slice( off ) );
url = url.slice( 0, off );
}
diff --git a/test/data/test3.html b/test/data/test3.html
index 909d41745..a7f862a86 100644
--- a/test/data/test3.html
+++ b/test/data/test3.html
@@ -1,3 +1,4 @@
This is a user
This is a user
This is a teacher
+This is a superuser
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 80531f984..4b4e408a3 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -1850,6 +1850,14 @@ module( "ajax", {
});
});
+ // Selector should be trimmed to avoid leading spaces (#14773)
+ asyncTest( "jQuery.fn.load( URL_SELECTOR with spaces )", 1, function() {
+ jQuery("#first").load( "data/test3.html #superuser ", function() {
+ strictEqual( jQuery( this ).children("div").length, 1, "Verify that specific elements were injected" );
+ start();
+ });
+ });
+
asyncTest( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", 2, function() {
jQuery("#first").load( url("data/name.html"), function() {
ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" );