Ever wondered why you jQuery’s $.ajax call gives back a 200 OK HTTP result with StatusCode 4 but does that in the error callback function?
I did just that recently, and found out that setting the wrong dataType and contentType will let you fetch data from an API but always result in an error if the result cannot be handled as expected.
I was retrieving a PDF (raw data) from an API function and the above scenario happened; everything seemed okay but the callback was not the success function but the error function… Setting the contentType from “application/json” to “application/pdf” and the dataType property to “text” did fix the callback function to be routed to “success” as expected.
Guess i’ll be shooting that one a lot faster. I mean, I can lookup this post from now on 😉