// Callback for when everything is done
// It is defined here because jslint complains if it is declared
// at the end of the function (which would be more logical and readable)
- function done( status, statusText, responses, headers ) {
+ function done( status, nativeStatusText, responses, headers ) {
// Called once
if ( state === 2 ) {
var isSuccess,
success,
error,
+ statusText = nativeStatusText,
response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
lastModified,
etag;
// Set data for the fake xhr object
jqXHR.status = status;
- jqXHR.statusText = statusText;
+ jqXHR.statusText = "" + ( nativeStatusText || statusText );
// Success/Error
if ( isSuccess ) {
ok( success, "context with circular reference did not generate an exception" );
});
+test( "jQuery.ajax - statusText" , 4, function() {
+ stop();
+ jQuery.ajax( url( "data/statusText.php?status=200&text=Hello" ) ).done(function( _, statusText, jqXHR ) {
+ strictEqual( statusText, "success", "callback status text ok for success" );
+ strictEqual( jqXHR.statusText, "Hello", "jqXHR status text ok for success" );
+ jQuery.ajax( url( "data/statusText.php?status=404&text=World" ) ).fail(function( jqXHR, statusText ) {
+ strictEqual( statusText, "error", "callback status text ok for error" );
+ strictEqual( jqXHR.statusText, "World", "jqXHR status text ok for error" );
+ start();
+ });
+ });
+});
+
test( "jQuery.ajax - statusCode" , function() {
var count = 12;