Side navigation
#12279 closed bug (invalid)
Opened August 13, 2012 11:49AM UTC
Closed August 14, 2012 11:13AM UTC
$.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.
Attachments (0)
Change History (4)
Changed August 13, 2012 02:06PM UTC by comment:1
owner: | → anonymous |
---|---|
status: | new → pending |
Changed August 13, 2012 02:20PM UTC by comment:2
status: | pending → 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.
Changed August 14, 2012 10:43AM UTC by comment:3
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.
Changed August 14, 2012 11:13AM UTC by comment:4
resolution: | → invalid |
---|---|
status: | new → closed |
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?