javascript - jQuery AJAX make command render 404 results -


i have following jquery

js:

$.ajax({     type: "post",     url: url,     async:false,     data: {} }) .done(function( msg ) {     console.log(msg); }).fail(function( jqxhr, textstatus ) {     alert('could not find file!'+textstatus); }); 

if page exists retrieve contents of html of page variable 'msg'.

if doesn't exist however... have custom 404 response want send users if attempt retrieve files through ajax request page. problem .fail response gives me jqxhr , textstatus no msg, can't show contents of 404 page!

if jquery ajax returns error (for example 404 not found) how can print results server?

i've looked around on jquery's documentation , not find anything, appreciated!

the argument jqxhr jquery object extends native xmlhttprequest object.

documentation here: jqxhr

since it's xhr object, should able find response (if exists) in property responsetext of object.

jqxhr.responsetext 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -