简体   繁体   English

Ajax加载PHP脚本时出现内部服务器错误(500)

[英]Internal Server Error (500) when Ajax loads PHP script

I am building an message board application using Javascript and PHP. 我正在使用Javascript和PHP构建留言板应用程序。 When I try to load a php script via Ajax, I get a 500 internal server error. 当我尝试通过Ajax加载php脚本时,出现500内部服务器错误。 If I load basic text instead of php, the Ajax call works fine and the text is displayed. 如果我加载基本文本而不是php,则Ajax调用可以正常工作并显示文本。

Anyone know why the server would have trouble with this? 有谁知道服务器为什么会遇到麻烦?

Here's my php file: 这是我的php文件:

<?php
    //Get input from my form
    $from = $_POST["guestbook_from"];
    $msg = $_POST["guestbook_msg"];
    $today = getdate(date("U"));

    recordMessage($from,$msg); //external php function, creates database record

    //Print some html
    echo("<p>");
    echo($msg);
    echo("</p>");
    echo("<h4>");
    echo($from);
    echo("<br />");
    echo("<small>");
    echo("posted on ");
    echo($today[month]);
    echo(" ");
    echo($today[mday]);
    echo(", ");
    echo($today[year]);
    echo("</small>");
    echo("</h4>");
?>

Beyond the HTTP status code, you need to investigate the server's error response too. 除了HTTP状态代码外,您还需要调查服务器的错误响应。 The response body might be having error messages, if any! 响应正文可能包含错误消息(如果有)!

You got to use Firebug . 您必须使用Firebug Enable the Console (or Net) tab and you will all HTTP requests and responses. 启用控制台(或网络)选项卡,您将所有HTTP请求和响应。

安慰

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM