AJAX Post to PHP返回500内部错误

I'm having an issue at the moment where AJAX requests are returning 500 Internal Server Errors, the code works fine on my local machine running MAMP, but as soon as I move it to another server it gives the 500 error.

I have seen that some people have had similar issues, but the majority of those cases have all resulted in typos in their code, this code works exactly as expected on MAMP.

Any advice would be greatly appreciated

Thanks

// Login AJAX

$('#login_form').on('submit', function(e) {

e.preventDefault();

var data = $(this).serialize();

$.ajax({
    url: 'core/process_login.php',
    type: 'post',
    data: {'formdata' : data},
    dataType:'json',
    success: function(data) {
        if(data.login_status === "failed") {
            alert(data.error_msg);
        }

        if(data.login_status === "success") {
            window.location.replace("/index.php");
        }
    }
});
});

<?php 

require('init.php');

$formdata = $_POST['formdata'];

parse_str($formdata);

if ($ldap->authenticate($username, $password)) {

    if ($ldap->user()->inGroup($username, "_BMSUsers")) {

        if(userProfileExists($username)) {

            createUserSession($username);

            $return = array("login_status" => "success");

            echo json_encode($return);

        } else {
            createUserProfile($username);

            createUserSession($username);

            $return = array("login_status" => "success");
            echo json_encode($return);
        }

    } else {

        // User is not part of the _BMSUSers AD group and therefore does not have sufficient permissions
        $return = array("login_status" => "failed", "error_msg" => "You do not have permission to access the BMS System. If you think this is a mistake, please contact the IT Department.");
        echo json_encode($return);
    }

} else {
    $return = array("login_status" => "failed", "error_msg" => "Username/Password Incorrect");
    echo json_encode($return);
}

?>

I've found the root of the error, the init.php pulls in a db_connection and ldap_connection files which contained some short tags, enabling short tags/adding long tags resolved the issue.

Thanks everyone for your assistance.

Problem can be in difference with php version on both server, i guess you are using some.outdated function. 500 internal error is server side error not client side

I had this problem when trying to configure a custom uploadifive script. The solution was move it to my own server and it worked fine. You're best contacting the webhost and asking them to investigate as they can use the error logs.