View AJAX response content in Chrome developer tools?

后端 未结 9 589
忘掉有多难
忘掉有多难 2020-12-02 17:04

Traditionally I use FireBug to debug my AJAX requests. It lets you examine both the contents of your request as well as the response that was sent back from the server. (it

9条回答
  •  余生分开走
    2020-12-02 17:10

    Solution for PHP:

    The reason could be that the requested-url (php page) has errors. But as many hostings has disabled the error-output, you need to enable that in requested .php file (put somewhere in the top of file):

    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    

    After that, you will see the response there.


    To hook manually:

    (function() {
        var origOpen = XMLHttpRequest.prototype.open;
        XMLHttpRequest.prototype.open = function() {
            this.addEventListener('load', function() {
                console.log(this);
            });
            origOpen.apply(this, arguments);
        };
    })();
    

提交回复
热议问题