Replace current page with ajax content

前端 未结 9 1255
南旧
南旧 2020-12-05 04:50

I have a page with a dialog window which sends ajax post data to server and receives a response. During development, there can be two responses - one regular (this is not th

9条回答
  •  离开以前
    2020-12-05 05:30

    Configure jQuery ajax setup as follows:

    $.ajaxSetup({
        error: handleXhrError
    });
    

    where handleXhrError function look like this:

    function handleXhrError(xhr) {
        document.open();
        document.write(xhr.responseText);
        document.close();
    }
    

    See also:

    • Handling of server-side HTTP 4nn/5nn errors in jQuery

提交回复
热议问题