javascript - How to show error message when my server is down / not available while making JQuery request? -
i have code goes this;
<a4j:commandlink actionlistener="#{controller.validate}" onclick="showfadeloadingimg();" oncomplete="confirmoperation();}" value="#{actionitem.actiondisplayname}" rerender="text1,text2"> </a4j:commandlink>
here, when server down, oncomplete event has jscript function confirmoperation(), gets executed , undesired output function being displayed. but, want is, when click button, want check whether can able connect server, , if not have show error message 'unable reach server' . can give me code example of achieving this?
create ajax request like-
var jqajax = $.ajax({ url: 'server url', type: "get/post", datatype: "type" , });
then, implement
jqajax.fail(function(jqxhr, textstatus, errorthrown){ //check textstatus });
check textstatus
, values - 0, 404, 500, timeout, abort, parsererror
Comments
Post a Comment