@@ -274,51 +274,51 @@ jQuery.extend({
274
274
275
275
// Create the request object; Microsoft failed to properly
276
276
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
277
- var xml = window . ActiveXObject ? new ActiveXObject ( "Microsoft.XMLHTTP" ) : new XMLHttpRequest ( ) ;
277
+ var xhr = window . ActiveXObject ? new ActiveXObject ( "Microsoft.XMLHTTP" ) : new XMLHttpRequest ( ) ;
278
278
279
279
// Open the socket
280
280
// Passing null username, generates a login popup on Opera (#2865)
281
281
if ( s . username )
282
- xml . open ( type , s . url , s . async , s . username , s . password ) ;
282
+ xhr . open ( type , s . url , s . async , s . username , s . password ) ;
283
283
else
284
- xml . open ( type , s . url , s . async ) ;
284
+ xhr . open ( type , s . url , s . async ) ;
285
285
286
286
// Need an extra try/catch for cross domain requests in Firefox 3
287
287
try {
288
288
// Set the correct header, if data is being sent
289
289
if ( s . data )
290
- xml . setRequestHeader ( "Content-Type" , s . contentType ) ;
290
+ xhr . setRequestHeader ( "Content-Type" , s . contentType ) ;
291
291
292
292
// Set the If-Modified-Since header, if ifModified mode.
293
293
if ( s . ifModified )
294
- xml . setRequestHeader ( "If-Modified-Since" ,
294
+ xhr . setRequestHeader ( "If-Modified-Since" ,
295
295
jQuery . lastModified [ s . url ] || "Thu, 01 Jan 1970 00:00:00 GMT" ) ;
296
296
297
297
// Set header so the called script knows that it's an XMLHttpRequest
298
- xml . setRequestHeader ( "X-Requested-With" , "XMLHttpRequest" ) ;
298
+ xhr . setRequestHeader ( "X-Requested-With" , "XMLHttpRequest" ) ;
299
299
300
300
// Set the Accepts header for the server, depending on the dataType
301
- xml . setRequestHeader ( "Accept" , s . dataType && s . accepts [ s . dataType ] ?
301
+ xhr . setRequestHeader ( "Accept" , s . dataType && s . accepts [ s . dataType ] ?
302
302
s . accepts [ s . dataType ] + ", */*" :
303
303
s . accepts . _default ) ;
304
304
} catch ( e ) { }
305
305
306
306
// Allow custom headers/mimetypes
307
- if ( s . beforeSend && s . beforeSend ( xml , s ) === false ) {
307
+ if ( s . beforeSend && s . beforeSend ( xhr , s ) === false ) {
308
308
// cleanup active request counter
309
309
s . global && jQuery . active -- ;
310
310
// close opended socket
311
- xml . abort ( ) ;
311
+ xhr . abort ( ) ;
312
312
return false ;
313
313
}
314
314
315
315
if ( s . global )
316
- jQuery . event . trigger ( "ajaxSend" , [ xml , s ] ) ;
316
+ jQuery . event . trigger ( "ajaxSend" , [ xhr , s ] ) ;
317
317
318
318
// Wait for a response to come back
319
319
var onreadystatechange = function ( isTimeout ) {
320
320
// The transfer is complete and the data is available, or the request timed out
321
- if ( ! requestDone && xml && ( xml . readyState == 4 || isTimeout == "timeout" ) ) {
321
+ if ( ! requestDone && xhr && ( xhr . readyState == 4 || isTimeout == "timeout" ) ) {
322
322
requestDone = true ;
323
323
324
324
// clear poll interval
@@ -328,15 +328,15 @@ jQuery.extend({
328
328
}
329
329
330
330
status = isTimeout == "timeout" && "timeout" ||
331
- ! jQuery . httpSuccess ( xml ) && "error" ||
332
- s . ifModified && jQuery . httpNotModified ( xml , s . url ) && "notmodified" ||
331
+ ! jQuery . httpSuccess ( xhr ) && "error" ||
332
+ s . ifModified && jQuery . httpNotModified ( xhr , s . url ) && "notmodified" ||
333
333
"success" ;
334
334
335
335
if ( status == "success" ) {
336
336
// Watch for, and catch, XML document parse errors
337
337
try {
338
338
// process the data (runs the xml through httpData regardless of callback)
339
- data = jQuery . httpData ( xml , s . dataType ) ;
339
+ data = jQuery . httpData ( xhr , s . dataType ) ;
340
340
} catch ( e ) {
341
341
status = "parsererror" ;
342
342
}
@@ -347,7 +347,7 @@ jQuery.extend({
347
347
// Cache Last-Modified header, if ifModified mode.
348
348
var modRes ;
349
349
try {
350
- modRes = xml . getResponseHeader ( "Last-Modified" ) ;
350
+ modRes = xhr . getResponseHeader ( "Last-Modified" ) ;
351
351
} catch ( e ) { } // swallow exception thrown by FF if header is not available
352
352
353
353
if ( s . ifModified && modRes )
@@ -357,14 +357,14 @@ jQuery.extend({
357
357
if ( ! jsonp )
358
358
success ( ) ;
359
359
} else
360
- jQuery . handleError ( s , xml , status ) ;
360
+ jQuery . handleError ( s , xhr , status ) ;
361
361
362
362
// Fire the complete handlers
363
363
complete ( ) ;
364
364
365
365
// Stop memory leaks
366
366
if ( s . async )
367
- xml = null ;
367
+ xhr = null ;
368
368
}
369
369
} ;
370
370
@@ -376,9 +376,9 @@ jQuery.extend({
376
376
if ( s . timeout > 0 )
377
377
setTimeout ( function ( ) {
378
378
// Check to see if the request is still happening
379
- if ( xml ) {
379
+ if ( xhr ) {
380
380
// Cancel the request
381
- xml . abort ( ) ;
381
+ xhr . abort ( ) ;
382
382
383
383
if ( ! requestDone )
384
384
onreadystatechange ( "timeout" ) ;
@@ -388,9 +388,9 @@ jQuery.extend({
388
388
389
389
// Send the data
390
390
try {
391
- xml . send ( s . data ) ;
391
+ xhr . send ( s . data ) ;
392
392
} catch ( e ) {
393
- jQuery . handleError ( s , xml , null , e ) ;
393
+ jQuery . handleError ( s , xhr , null , e ) ;
394
394
}
395
395
396
396
// firefox 1.5 doesn't fire statechange for sync requests
@@ -404,66 +404,66 @@ jQuery.extend({
404
404
405
405
// Fire the global callback
406
406
if ( s . global )
407
- jQuery . event . trigger ( "ajaxSuccess" , [ xml , s ] ) ;
407
+ jQuery . event . trigger ( "ajaxSuccess" , [ xhr , s ] ) ;
408
408
}
409
409
410
410
function complete ( ) {
411
411
// Process result
412
412
if ( s . complete )
413
- s . complete ( xml , status ) ;
413
+ s . complete ( xhr , status ) ;
414
414
415
415
// The request was completed
416
416
if ( s . global )
417
- jQuery . event . trigger ( "ajaxComplete" , [ xml , s ] ) ;
417
+ jQuery . event . trigger ( "ajaxComplete" , [ xhr , s ] ) ;
418
418
419
419
// Handle the global AJAX counter
420
420
if ( s . global && ! -- jQuery . active )
421
421
jQuery . event . trigger ( "ajaxStop" ) ;
422
422
}
423
423
424
424
// return XMLHttpRequest to allow aborting the request etc.
425
- return xml ;
425
+ return xhr ;
426
426
} ,
427
427
428
- handleError : function ( s , xml , status , e ) {
428
+ handleError : function ( s , xhr , status , e ) {
429
429
// If a local callback was specified, fire it
430
- if ( s . error ) s . error ( xml , status , e ) ;
430
+ if ( s . error ) s . error ( xhr , status , e ) ;
431
431
432
432
// Fire the global callback
433
433
if ( s . global )
434
- jQuery . event . trigger ( "ajaxError" , [ xml , s , e ] ) ;
434
+ jQuery . event . trigger ( "ajaxError" , [ xhr , s , e ] ) ;
435
435
} ,
436
436
437
437
// Counter for holding the number of active queries
438
438
active : 0 ,
439
439
440
440
// Determines if an XMLHttpRequest was successful or not
441
- httpSuccess : function ( r ) {
441
+ httpSuccess : function ( xhr ) {
442
442
try {
443
443
// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
444
- return ! r . status && location . protocol == "file:" ||
445
- ( r . status >= 200 && r . status < 300 ) || r . status == 304 || r . status == 1223 ||
446
- jQuery . browser . safari && r . status == undefined ;
444
+ return ! xhr . status && location . protocol == "file:" ||
445
+ ( xhr . status >= 200 && xhr . status < 300 ) || xhr . status == 304 || xhr . status == 1223 ||
446
+ jQuery . browser . safari && xhr . status == undefined ;
447
447
} catch ( e ) { }
448
448
return false ;
449
449
} ,
450
450
451
451
// Determines if an XMLHttpRequest returns NotModified
452
- httpNotModified : function ( xml , url ) {
452
+ httpNotModified : function ( xhr , url ) {
453
453
try {
454
- var xmlRes = xml . getResponseHeader ( "Last-Modified" ) ;
454
+ var xhrRes = xhr . getResponseHeader ( "Last-Modified" ) ;
455
455
456
456
// Firefox always returns 200. check Last-Modified date
457
- return xml . status == 304 || xmlRes == jQuery . lastModified [ url ] ||
458
- jQuery . browser . safari && xml . status == undefined ;
457
+ return xhr . status == 304 || xhrRes == jQuery . lastModified [ url ] ||
458
+ jQuery . browser . safari && xhr . status == undefined ;
459
459
} catch ( e ) { }
460
460
return false ;
461
461
} ,
462
462
463
- httpData : function ( r , type ) {
464
- var ct = r . getResponseHeader ( "content-type" ) ,
463
+ httpData : function ( xhr , type ) {
464
+ var ct = xhr . getResponseHeader ( "content-type" ) ,
465
465
xml = type == "xml" || ! type && ct && ct . indexOf ( "xml" ) >= 0 ,
466
- data = xml ? r . responseXML : r . responseText ;
466
+ data = xml ? xhr . responseXML : xhr . responseText ;
467
467
468
468
if ( xml && data . documentElement . tagName == "parsererror" )
469
469
throw "parsererror" ;
0 commit comments