【问题标题】:Why is my ajax call resulting in this 500 error?为什么我的 ajax 调用会导致这个 500 错误?
【发布时间】:2014-01-26 22:26:54
【问题描述】:

我有一个 ajax 调用:

$.ajax({
    url: "http://localhost/kidsKnitsDB/edit.php",
    type: "post",
    data: id,
    beforeSend: function(response){alert('Sending');},
        success: function(response){ alert('success');},
        error: function(response){alert('failed');},
        complete: function(response){alert('finished');},
});

这会导致如下所示的 500 服务器错误:

Request URL:    http://localhost/kidsKnitsDB/edit.php
Request Method:     POST
Status Code:    HTTP/1.0 500 Internal Server Error
Request Headers 17:09:44.000
X-Requested-With:   XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0
Referer:    http://localhost/kidsKnitsDB/index.php
Pragma: no-cache
Host:   localhost
Content-Length: 0
Connection: keep-alive
Cache-Control:  no-cache
Accept-Language:    en-US,en;q=0.5
Accept-Encoding:    gzip, deflate
Accept: */*
Response Headers Δ4ms
X-Powered-By:   PHP/5.3.10-1ubuntu3.9
Vary:   Accept-Encoding
Server: Apache/2.2.22 (Ubuntu)
Date:   Sun, 26 Jan 2014 22:09:44 GMT
Content-Type:   text/html
Content-Length: 192
Content-Encoding:   gzip
Connection: close

如果有人打电话求助,我们将不胜感激,我不确定我为什么会得到这个。我也很好奇 url 属性应该是原样还是应该是../edit.php?我想我拥有它的方式是正确的,因此 apache 可以解释 php。

【问题讨论】:

  • HTTP 5xx = 服务器故障。接收调用的函数正在死亡。检查日志。
  • 500 内部服务器错误检查后参数听起来不正确
  • 反对者应发表评论以解释。这个问题在我看来是合理的。
  • 我要发一个号码,应该连载吗?

标签: php jquery ajax apache internal-server-error


【解决方案1】:

这是我的 php 脚本中未定义的调用,这是错误。不过这只是一个错字。

【讨论】:

  • 如果问题只是“错字”,请删除问题。它对寻找答案的人没有任何价值。
  • 我会,但我显然不允许删除它。
【解决方案2】:

您要做的是检查服务器错误日志。这将为您了解服务器遇到错误的原因和位置提供了一个良好的开端。

由于它是服务器端错误,请不要试图猜测问题是什么(是发布数据吗?是代码错误吗?) 只看日志。

如果您没有错误日志,您可能希望按照 Apache 网站上的说明启用日志记录错误。 (我似乎无法粘贴链接,所以谷歌:“配置 Web 日志 apache”)

在 Ubuntu 上,默认 v 主机的错误日志是默认开启的,它们在 /var/log/apache2/ 处退出

调试愉快:)

【讨论】:

    猜你喜欢
    • 2012-09-03
    • 2012-02-21
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多