Html 如何解决 500 内部服务器错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1864905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:29:56  来源:igfitidea点击:

How to resolve 500 Internal Server Error?

htmlajax

提问by MalarN

I am getting "500 Internal Server Error" when I used ajax call. What is causing this problem? How to resolve it?

使用 ajax 调用时出现“500 内部服务器错误”。是什么导致了这个问题?如何解决?

回答by HorusKol

debugging, fixing, and resolving a server error from an Ajax call is exactly the same process as any other request.

调试、修复和解决来自 Ajax 调用的服务器错误与任何其他请求的过程完全相同。

  1. Check the web server error logs for any indications of what the error is

  2. Introduce debug statements into the serverside code around where the error is occuring (and add a little bit to your ajax request to dump all the response as plain text)

  1. 检查 Web 服务器错误日志以了解错误是什么

  2. 在发生错误的服务器端代码中引入调试语句(并在您的 ajax 请求中添加一点以将所有响应转储为纯文本)

It may also be useful to copy the URL and querystring used in the Ajax call and paste it into your browser to view any responses.

复制 Ajax 调用中使用的 URL 和查询字符串并将其粘贴到浏览器中以查看任何响应也可能很有用。

Firebug for Firefox is also a useful diagnostic tool for testing what is being sent as part of the Ajax call and what is being sent back as a response.

Firebug for Firefox 也是一个有用的诊断工具,用于测试作为 Ajax 调用的一部分发送的内容以及作为响应发送的内容。

回答by row1

Use fiddleror firebug to look at your network request/response.

使用fiddler或 firebug 查看您的网络请求/响应。

It looks like you may be using perl? Try adding use CGI::Carp qw(fatalsToBrowser);on a new line after your path to perl declaration.

看起来您可能正在使用 perl?尝试CGI::Carp qw(fatalsToBrowser);在 perl 声明的路径之后添加一个新行。

回答by ariefbayu

My step usually (in particular order):

我的步骤通常(按特定顺序):

  1. open firebug and look up the particular ajax request from console. Then, see the parameter, header, and URL request. Examine each data to see what goes wrong. If it all seems OK
  2. I will look at my server log (httpd-error.log on Apache) and check any particular error that came from that request.
  3. Fix what is wrong based on all there checking.
  1. 打开 firebug 并从控制台查找特定的 ajax 请求。然后,查看参数、标头和 URL 请求。检查每个数据,看看哪里出了问题。如果一切正常
  2. 我将查看我的服务器日志(Apache 上的 httpd-error.log)并检查来自该请求的任何特定错误。
  3. 根据所有检查修复错误。

回答by Isidro López

I was working on a customer's server and had problems executing PHP code. I checked on the CPannel the errors and it was just a permissions error. The PHP files had to be set with non writable permissions for groups. In my case setting the permissions to 644 got everything working.

我在客户的服务器上工作并且在执行 PHP 代码时遇到问题。我在 CPanel 上检查了错误,这只是一个权限错误。PHP 文件必须设置为组的不可写权限。在我的情况下,将权限设置为 644 使一切正常。

回答by Nidhanshu Sharma

I was also facing the same error today. It mostly occurs because of wrong folder/file name because name of folders and files when linking/ sending ajax requests is case-sensitive on actual servers (not in Server simulators e.g. WAMP/XAMPP). So, check your file path to which you are sending the request and the problem may get solved.

我今天也面临同样的错误。它主要是由于错误的文件夹/文件名而发生的,因为链接/发送 ajax 请求时文件夹和文件的名称在实际服务器上区分大小写(不在服务器模拟器中,例如 WAMP/XAMPP)。因此,请检查您将请求发送到的文件路径,问题可能会得到解决。

回答by Carl Smotricz

You created and fired off a request to a server with whatever you did in Ajax. So far, so good. The server tried to process your request but ran into an error condition. That's usually caused by some bug in the server code.

您使用在 Ajax 中所做的一切创建并向服务器发出请求。到现在为止还挺好。服务器尝试处理您的请求,但遇到错误情况。这通常是由服务器代码中的一些错误引起的。

As John Saunders advises, you can usually get more information on the server-side problem by looking into its logs.

正如 John Saunders 所建议的那样,您通常可以通过查看日志来获取有关服务器端问题的更多信息。

回答by John Saunders

If your server is running Windows, then look in the event log and see what server error occurred.

如果您的服务器运行的是 Windows,则查看事件日志并查看发生了什么服务器错误。

回答by Artem Russakovskii

Look in the server log, which on Linux is normally in something like /var/log/apache2 or /var/log/httpd.

查看服务器日志,它在 Linux 上通常位于 /var/log/apache2 或 /var/log/httpd 之类的内容中。

Download Firebug, intercept the ajax call and load it in the browser or look at its output. Make sure you server is set to report errors (look at php.ini for PHP settings, for example). Whatever is causing it is probably going to show up.

下载 Firebug,拦截 ajax 调用并将其加载到浏览器中或查看其输出。确保您的服务器设置为报告错误(例如,查看 php.ini 中的 PHP 设置)。无论是什么原因,它都可能会出现。

Make sure you don't actually throw the error 500 yourself in the code.

确保您实际上没有在代码中自己抛出错误 500。

If you use PHP, then use a debugger, such as PHPEd or xdebug and step through the code. That's the way I debug my PHP and it's the best way, though takes some time to set up.

如果您使用 PHP,则使用调试器(例如 PHPEd 或 xdebug)并逐步执行代码。这就是我调试 PHP 的方式,它是最好的方式,虽然需要一些时间来设置。