aboutsummaryrefslogtreecommitdiffstats
path: root/src/ajax
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-08-16 09:59:58 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-09-07 20:03:50 +0300
commit10fdad742a2a6aa9f0e00b3e04fc5264797c53c7 (patch)
tree6b6d7b1375ff88f4bebbfa0703f7b595eb485df9 /src/ajax
parent7aa46e0df8a673e6b00550bbbbed21eed50108b7 (diff)
downloadjquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.tar.gz
jquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.zip
Build: Update jscs and lint files
Fixes gh-2056
Diffstat (limited to 'src/ajax')
-rw-r--r--src/ajax/jsonp.js26
-rw-r--r--src/ajax/load.js18
-rw-r--r--src/ajax/parseJSON.js4
-rw-r--r--src/ajax/parseXML.js4
-rw-r--r--src/ajax/script.js17
-rw-r--r--src/ajax/var/location.js4
-rw-r--r--src/ajax/var/nonce.js4
-rw-r--r--src/ajax/var/rquery.js6
-rw-r--r--src/ajax/xhr.js26
9 files changed, 59 insertions, 50 deletions
diff --git a/src/ajax/jsonp.js b/src/ajax/jsonp.js
index f469344e0..666e5d1e6 100644
--- a/src/ajax/jsonp.js
+++ b/src/ajax/jsonp.js
@@ -1,4 +1,4 @@
-define([
+define( [
"../core",
"./var/nonce",
"./var/rquery",
@@ -9,14 +9,14 @@ var oldCallbacks = [],
rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings
-jQuery.ajaxSetup({
+jQuery.ajaxSetup( {
jsonp: "callback",
jsonpCallback: function() {
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
this[ callback ] = true;
return callback;
}
-});
+} );
// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
@@ -26,7 +26,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
"url" :
typeof s.data === "string" &&
( s.contentType || "" )
- .indexOf("application/x-www-form-urlencoded") === 0 &&
+ .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
rjsonp.test( s.data ) && "data"
);
@@ -46,14 +46,14 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}
// Use data converter to retrieve json after script execution
- s.converters["script json"] = function() {
+ s.converters[ "script json" ] = function() {
if ( !responseContainer ) {
jQuery.error( callbackName + " was not called" );
}
return responseContainer[ 0 ];
};
- // force json dataType
+ // Force json dataType
s.dataTypes[ 0 ] = "json";
// Install callback
@@ -63,7 +63,8 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
};
// Clean-up function (fires after converters)
- jqXHR.always(function() {
+ jqXHR.always( function() {
+
// If previous value didn't exist - remove it
if ( overwritten === undefined ) {
jQuery( window ).removeProp( callbackName );
@@ -75,10 +76,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
// Save back as free
if ( s[ callbackName ] ) {
- // make sure that re-using the options doesn't screw things around
+
+ // Make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback;
- // save the callback name for future use
+ // Save the callback name for future use
oldCallbacks.push( callbackName );
}
@@ -88,11 +90,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}
responseContainer = overwritten = undefined;
- });
+ } );
// Delegate to script
return "script";
}
-});
+} );
-});
+} );
diff --git a/src/ajax/load.js b/src/ajax/load.js
index 8326e9287..82f0cf308 100644
--- a/src/ajax/load.js
+++ b/src/ajax/load.js
@@ -1,4 +1,4 @@
-define([
+define( [
"../core",
"../core/parseHTML",
"../ajax",
@@ -13,7 +13,7 @@ define([
jQuery.fn.load = function( url, params, callback ) {
var selector, type, response,
self = this,
- off = url.indexOf(" ");
+ off = url.indexOf( " " );
if ( off > -1 ) {
selector = jQuery.trim( url.slice( off ) );
@@ -34,7 +34,7 @@ jQuery.fn.load = function( url, params, callback ) {
// If we have elements to modify, make the request
if ( self.length > 0 ) {
- jQuery.ajax({
+ jQuery.ajax( {
url: url,
// If "type" variable is undefined, then "GET" method will be used.
@@ -43,7 +43,7 @@ jQuery.fn.load = function( url, params, callback ) {
type: type || "GET",
dataType: "html",
data: params
- }).done(function( responseText ) {
+ } ).done( function( responseText ) {
// Save response for use in complete callback
response = arguments;
@@ -52,7 +52,7 @@ jQuery.fn.load = function( url, params, callback ) {
// If a selector was specified, locate the right elements in a dummy div
// Exclude scripts to avoid IE 'Permission Denied' errors
- jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
+ jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
// Otherwise use the full result
responseText );
@@ -60,14 +60,14 @@ jQuery.fn.load = function( url, params, callback ) {
// If the request succeeds, this function gets "data", "status", "jqXHR"
// but they are ignored because response was set above.
// If it fails, this function gets "jqXHR", "status", "error"
- }).always( callback && function( jqXHR, status ) {
+ } ).always( callback && function( jqXHR, status ) {
self.each( function() {
callback.apply( self, response || [ jqXHR.responseText, status, jqXHR ] );
- });
- });
+ } );
+ } );
}
return this;
};
-});
+} );
diff --git a/src/ajax/parseJSON.js b/src/ajax/parseJSON.js
index 3a96d15b9..11918b06d 100644
--- a/src/ajax/parseJSON.js
+++ b/src/ajax/parseJSON.js
@@ -1,4 +1,4 @@
-define([
+define( [
"../core"
], function( jQuery ) {
@@ -10,4 +10,4 @@ jQuery.parseJSON = function( data ) {
return jQuery.parseJSON;
-});
+} );
diff --git a/src/ajax/parseXML.js b/src/ajax/parseXML.js
index 962dc8887..6599aaf5b 100644
--- a/src/ajax/parseXML.js
+++ b/src/ajax/parseXML.js
@@ -1,4 +1,4 @@
-define([
+define( [
"../core"
], function( jQuery ) {
@@ -24,4 +24,4 @@ jQuery.parseXML = function( data ) {
return jQuery.parseXML;
-});
+} );
diff --git a/src/ajax/script.js b/src/ajax/script.js
index ede551708..60b1fb6b0 100644
--- a/src/ajax/script.js
+++ b/src/ajax/script.js
@@ -1,11 +1,11 @@
-define([
+define( [
"../core",
"../var/document",
"../ajax"
], function( jQuery, document ) {
// Install script dataType
-jQuery.ajaxSetup({
+jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
@@ -19,7 +19,7 @@ jQuery.ajaxSetup({
return text;
}
}
-});
+} );
// Handle cache's special case and crossDomain
jQuery.ajaxPrefilter( "script", function( s ) {
@@ -29,19 +29,20 @@ jQuery.ajaxPrefilter( "script", function( s ) {
if ( s.crossDomain ) {
s.type = "GET";
}
-});
+} );
// Bind script tag hack transport
jQuery.ajaxTransport( "script", function( s ) {
+
// This transport only deals with cross domain requests
if ( s.crossDomain ) {
var script, callback;
return {
send: function( _, complete ) {
- script = jQuery("<script>").prop({
+ script = jQuery( "<script>" ).prop( {
charset: s.scriptCharset,
src: s.url
- }).on(
+ } ).on(
"load error",
callback = function( evt ) {
script.remove();
@@ -62,6 +63,6 @@ jQuery.ajaxTransport( "script", function( s ) {
}
};
}
-});
+} );
-});
+} );
diff --git a/src/ajax/var/location.js b/src/ajax/var/location.js
index 4c9cf4a4c..ff9578e99 100644
--- a/src/ajax/var/location.js
+++ b/src/ajax/var/location.js
@@ -1,3 +1,3 @@
-define(function() {
+define( function() {
return window.location;
-});
+} );
diff --git a/src/ajax/var/nonce.js b/src/ajax/var/nonce.js
index 0871aae88..83fd557c8 100644
--- a/src/ajax/var/nonce.js
+++ b/src/ajax/var/nonce.js
@@ -1,5 +1,5 @@
-define([
+define( [
"../../core"
], function( jQuery ) {
return jQuery.now();
-});
+} );
diff --git a/src/ajax/var/rquery.js b/src/ajax/var/rquery.js
index 500a77a08..0502146ca 100644
--- a/src/ajax/var/rquery.js
+++ b/src/ajax/var/rquery.js
@@ -1,3 +1,3 @@
-define(function() {
- return (/\?/);
-});
+define( function() {
+ return ( /\?/ );
+} );
diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js
index 545bb26c9..7ac141e64 100644
--- a/src/ajax/xhr.js
+++ b/src/ajax/xhr.js
@@ -1,4 +1,4 @@
-define([
+define( [
"../core",
"../var/support",
"../ajax"
@@ -11,8 +11,10 @@ jQuery.ajaxSettings.xhr = function() {
};
var xhrSuccessStatus = {
- // file protocol always yields status code 0, assume 200
+
+ // File protocol always yields status code 0, assume 200
0: 200,
+
// Support: IE9
// #1450: sometimes IE returns 1223 when it should be 204
1223: 204
@@ -22,7 +24,7 @@ var xhrSuccessStatus = {
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
support.ajax = xhrSupported = !!xhrSupported;
-jQuery.ajaxTransport(function( options ) {
+jQuery.ajaxTransport( function( options ) {
var callback;
// Cross domain only allowed if supported through XMLHttpRequest
@@ -57,8 +59,8 @@ jQuery.ajaxTransport(function( options ) {
// akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided.
- if ( !options.crossDomain && !headers["X-Requested-With"] ) {
- headers["X-Requested-With"] = "XMLHttpRequest";
+ if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
+ headers[ "X-Requested-With" ] = "XMLHttpRequest";
}
// Set headers
@@ -76,7 +78,8 @@ jQuery.ajaxTransport(function( options ) {
xhr.abort();
} else if ( type === "error" ) {
complete(
- // file: protocol always yields status 0; see #8605, #14207
+
+ // File: protocol always yields status 0; see #8605, #14207
xhr.status,
xhr.statusText
);
@@ -84,6 +87,7 @@ jQuery.ajaxTransport(function( options ) {
complete(
xhrSuccessStatus[ xhr.status ] || xhr.status,
xhr.statusText,
+
// Support: IE9
// Accessing binary-data responseText throws an exception
// (#11426)
@@ -99,15 +103,17 @@ jQuery.ajaxTransport(function( options ) {
// Listen to events
xhr.onload = callback();
- xhr.onerror = callback("error");
+ xhr.onerror = callback( "error" );
// Create the abort callback
- callback = callback("abort");
+ callback = callback( "abort" );
try {
+
// Do send the request (this may raise an exception)
xhr.send( options.hasContent && options.data || null );
} catch ( e ) {
+
// #14683: Only rethrow if this hasn't been notified as an error yet
if ( callback ) {
throw e;
@@ -122,6 +128,6 @@ jQuery.ajaxTransport(function( options ) {
}
};
}
-});
+} );
-});
+} );