How do I figure out why a JQuery ajax request failed -


i have ajax request should failing. , there's no information why. code is:

$.getjson( "http://localhost:62178/document?filename=c:/test/dave.docx", function( data ) {     console.log("read = " + data); }).done(function(e) {     console.log( "second success" ); })     .fail(function(e) {         console.log( "error" );     })     .always(function(e) {         console.log( "complete" );     }); 

according fiddler rest query returning 200 , returned body expected json. calling fail(e) , object e bunch of functions , 3 properties are: readystate: 0 responsetext: "" statustext: "error"

the generated json created asp.net web api 2 , i'm confident it's valid. , valid. in form:

{ success: true, document: { ...   } } 

how figure out jquery unhappy with?

update: figured out problem (cross domain request). original question remains, how figure out why ajax request failed vars passed in fail() function?

you can use .fail function after getjson call (like have already) , output parameters so:

.fail(function(jqxhr, textstatus){ //error     console.log('failure: ' + textstatus);     console.log(jqxhr); }); 

now in console , can see textstatus , see jqxhr object. object contains additional information might helpful. let me know if works or if unclear! thanks!


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -