jquery ajax ignores 500 status error

前端 未结 3 2025
情歌与酒
情歌与酒 2020-12-10 13:02

I\'m making some GET requests to an App Engine app, testing in Chrome. Whilst I can see in javascript console that some calls result in a 500 server error, I can\'t seem to

3条回答
  •  星月不相逢
    2020-12-10 13:35

    It doesn't look like you're using jQuery's document.ready binding correctly. The $().ready(...) version is more-or-less deprecated. Try one of these instead:

    $(document).ready(function() {
        $.ajaxSetup({
            error: function(x, e) {
                if (x.status == 500) {
                    alert('Internel Server Error.');
                }
            }
        });
    });
    

    or the shorthand:

    $(function() {
        $.ajaxSetup({
            error: function(x, e) {
                if (x.status == 500) {
                    alert('Internel Server Error.');
                }
            }
        });
    });
    

提交回复
热议问题