Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12279 closed bug (invalid)

$.ajax().fail() is called even if i get a status 200 response

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

Description

hello there guys, i'm setting up an ajax request and get a status 200 response. .done() is not even called and instead .fail() is called. my code looks like this:

jQuery.ajax({
	url : url,
	type : customRequest,
	dataType : 'application/x-www-form-urlencoded',
	data: requestArray,
	processData : true,
	beforeSend : function(req) {
		req.setRequestHeader('Authorization', 'someauthdataheader');
		req.setRequestHeader('User-Agent','someuseragentheader');
		req.setRequestHeader('Accept', 'someaccept header');
	}
}).done(function(success, status, xhr) {
	console.log(xhr);
	console.log("i'm in done");
}).fail(function(xhr, error, status) {
	console.log(xhr);
	console.log("i'm in fail");
});

This is a cross domain request, in Google Chrome (Version 21.0.1180.75 m) with " --allow-cross-origin-auth-prompt --disable-web-security" as parameters to get cross domain working.

xhr.responseText gives me the exact json i was awaiting for a successfull request and xhr.status is 200.

Hope this helps.

Change History (4)

comment:1 Changed 7 years ago by dmethvin

Owner: set to anonymous
Status: newpending

A request can fail if the JSON is not valid, there is more to a failure than just a 200 response. What does your JSON response look like?

comment:2 Changed 7 years ago by anonymous

Status: pendingnew

console.log(xhr);

responseText: "{"status":{"statusCode":"0000","statusMessage":"Success."}}"

so my JSON response is the above string without the quotation marks that are the outermost.

comment:3 Changed 7 years ago by anonymous

this bug report can be closed mixed up dataType and contentType. worked now with the change to contentType.

thx to shoke on IRC to point that out to me.

comment:4 Changed 7 years ago by mikesherov

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.