views:

37

answers:

1

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

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

Ankit Jain