dongmi5015 2018-02-15 15:18
浏览 92
已采纳

哪里可以找到明确的jquery ajax调用错误信息?

I am trying to find a place where an error occurs in my project to be able to throw an error message from there.

Within the project I am debugging, an ajax post call is executed. Somewhere earlier in PHP the code causing the error is executing. In my case, a parse error is causing the problem. An array value is tried to be fetched out of a boolean variable. But at that place, nothing goes wrong and the code continues to run.

Failing PHP code:

if ($booleanValue['not-existing-arrayvalue'] == 'true') { }

The ajax code that is been called at some point:

var call = $.ajax(options);
call.done(function (result) { ... })
.fail(function(xhr, text_status){ ... }

Inside of the fail method, the error becomes clear, but it is stored within a huge html response, so hard to fetch from the whole value. It is stored within xhr.responseText:

<br />↵<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>↵<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: selected in "C:\workspace\project\class.php" on line <i>14</i></th></tr>↵<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th>

This is just a part of the value, containing the line number causing the error.

Does anybody have an idea where this ajax failing response text comes from and if it is possible to get a cleaner message instead of a big html output string?

  • 写回答

2条回答 默认 最新

  • douxian6260 2018-02-15 15:35
    关注

    There is an error on line 14 of your class.php file, looks like you try to do an out of bounds call on an array. Therefore php returns an error response. Jquery detects that a error response is given a runs the fail function.

    If you would look at the http request using a tool like fiddler then you could see that a http error code was returned instead of the normal 200. (Probably 500 - Internal Server Error).

    If you don't get a clear php error message then you should check the log files and/or your server configuration.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 CST怎么把天线放在座椅环境中并仿真
  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?