Bug Tracker

Modify

Ticket #12279 (closed bug: invalid)

Opened 9 months ago

Last modified 9 months ago

$.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:
Blocking: Blocked by:

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

comment:1 Changed 9 months ago by dmethvin

  • Owner set to anonymous
  • Status changed from new to pending

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 9 months ago by anonymous

  • Status changed from pending to new

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 9 months 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 9 months ago by mikesherov

  • Status changed from new to closed
  • Resolution set to invalid

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.