且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何调试ajax响应?

更新时间:2022-06-05 09:10:15

经过十分必要的深夜休息,我用了很多时间解决了这个问题头脑清晰。

After a much needed 10 hour break into the night, I solved the issue with a much clearer mind. I removed the dataType row and it worked for me.

听起来很愚蠢,PHP页面中的表不是JSON格式,所以当jQuery尝试

As silly as it may sound, the table in the PHP page was not in JSON format, so when jQuery tries to parse it as such, it fails.

希望它对您有帮助。如果不是,请在此处查看更多建议。

Hope it helps for you. If not, check out more suggestions here.

之前

  $.ajax({
                    type: 'POST',
                    dataType : 'json',
                    url: 'queries/getsocial.php',
                    data:nvalues,
                    success: function(response)
                    {

                        console.log(response);//does not print in the console
                    }

            });

之后(立即运行)

  $.ajax({
                    type: 'POST',
                    url: 'queries/getsocial.php',
                    data:nvalues,
                    success: function(response)
                    {

                        console.log(response);//yes prints in the console
                    }

            });