MCPcopy Create free account
hub / github.com/JsAaron/jQuery / onreadystatechange

Function onreadystatechange

1.2.6/src/ajax.js:319–369  ·  view source on GitHub ↗
(isTimeout)

Source from the content-addressed store, hash-verified

317
318 // Wait for a response to come back
319 var onreadystatechange = function(isTimeout){
320 // The transfer is complete and the data is available, or the request timed out
321 if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
322 requestDone = true;
323
324 // clear poll interval
325 if (ival) {
326 clearInterval(ival);
327 ival = null;
328 }
329
330 status = isTimeout == "timeout" && "timeout" ||
331 !jQuery.httpSuccess( xhr ) && "error" ||
332 s.ifModified && jQuery.httpNotModified( xhr, s.url ) && "notmodified" ||
333 "success";
334
335 if ( status == "success" ) {
336 // Watch for, and catch, XML document parse errors
337 try {
338 // process the data (runs the xml through httpData regardless of callback)
339 data = jQuery.httpData( xhr, s.dataType, s.dataFilter );
340 } catch(e) {
341 status = "parsererror";
342 }
343 }
344
345 // Make sure that the request was successful or notmodified
346 if ( status == "success" ) {
347 // Cache Last-Modified header, if ifModified mode.
348 var modRes;
349 try {
350 modRes = xhr.getResponseHeader("Last-Modified");
351 } catch(e) {} // swallow exception thrown by FF if header is not available
352
353 if ( s.ifModified && modRes )
354 jQuery.lastModified[s.url] = modRes;
355
356 // JSONP handles its own success callback
357 if ( !jsonp )
358 success();
359 } else
360 jQuery.handleError(s, xhr, status);
361
362 // Fire the complete handlers
363 complete();
364
365 // Stop memory leaks
366 if ( s.async )
367 xhr = null;
368 }
369 };
370
371 if ( s.async ) {
372 // don't attach the handler to the request, just poll it instead

Callers 1

ajax.jsFile · 0.85

Calls 2

successFunction · 0.85
completeFunction · 0.85

Tested by

no test coverage detected