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条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!