内部服务器错误:Ajax Post

时间:2017-12-01 12:03:17

标签: javascript php ajax

有人可以帮我弄清楚这里发生了什么吗?我不能100%确定它为什么显示内部服务器错误。

控制台出错:

jquery.min.js:4 POST http://*******.*********.com/lib/ajax/login.php 500 (Internal Server Error)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
login_user @ user.js?ver=1:31
(anonymous) @ user.js?ver=1:11
dispatch @ jquery.min.js:3
q.handle @ jquery.min.js:3

将错误编码:

$.ajax({
        url: '/lib/ajax/login.php',
        type: "POST",
        data: dataObject,
        dataType: 'json',
        success: function (result) {
            if(result === true){
                $("#name_container").hide();
                $("#pass_container").show();
                $("#login_errors").empty();
            }
            if(result === false){
                $("#login_errors").empty().append("<p>Username does not exists. Please try again.</p>");
            }
        },
        error: function (req, status, error){
        }
    });

Login.php:

<?php 
    require_once($_SERVER['DOCUMENT_ROOT'] "/lib/load.php");

    if(!isset($User)) $User = new User;

    if(isset($_POST["action"]) && $_POST["action"]){
        $User->_populate($_POST);
        if($User->login()){
            if($User->action === "check_user"){
                if(isset($User->user_id) && $User->user_id){
                    $_SESSION['user'] = $User->user_id;
                    echo json_encode(true);
                    exit;
                }
            }
            if($User->action === "check_user_website"){
                echo json_encode(array("token" => $User->token, "response" => true));
                exit;
            }
            if($User->action === "check_pass"){
                echo json_encode(array("token" => $User->token, "response" => true));
                exit;
            }
        }
        echo json_encode(false);
        exit;
    }
?>

0 个答案:

没有答案