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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -