Logic Artist
Logic Artist

Reputation: 996

Internal Server Error (500) when Ajax loads PHP script

I am building an message board application using Javascript and PHP. When I try to load a php script via Ajax, I get a 500 internal server error. If I load basic text instead of php, the Ajax call works fine and the text is displayed.

Anyone know why the server would have trouble with this?

Here's my php file:

<?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>");
?>

Upvotes: 0

Views: 1669

Answers (1)

ankitjaininfo
ankitjaininfo

Reputation: 12372

Beyond the HTTP status code, you need to investigate the server's error response too. The response body might be having error messages, if any!

You got to use Firebug. Enable the Console (or Net) tab and you will all HTTP requests and responses.

console

Upvotes: 1

Related Questions