首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AJAX Post到PHP返回500内部错误

问AJAX Post到PHP返回500内部错误
EN

Stack Overflow用户
提问于 2014-11-04 17:01:31
回答 3查看 634关注 0票数 0

在AJAX请求返回500个内部服务器错误时,我遇到了一个问题,代码在运行MAMP的本地机器上运行良好,但是一旦我将它移到另一台服务器上,它就会产生500错误。

我看到有些人也有类似的问题,但大多数情况下都会导致他们的代码输入错误,这段代码在MAMP上的工作原理与预期完全一样。

如有任何建议,将不胜感激。

谢谢

代码语言:javascript
复制
// 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);
}

?>
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-11-05 10:36:17

我已经找到了错误的根源,init.php提取了一个包含一些短标记的db_connection和ldap_connection文件,启用了短标记/添加了长标记解决了这个问题。

谢谢大家的帮助。

票数 0
EN

Stack Overflow用户

发布于 2014-11-04 17:11:58

问题可能与两台服务器上的php版本不同,我猜您正在使用some.outdated函数。500内部错误是服务器端错误,而不是客户端错误。

票数 1
EN

Stack Overflow用户

发布于 2014-11-04 17:26:56

在试图配置自定义上载5脚本时,我遇到了这个问题。解决方案是把它移到我自己的服务器上,它运行得很好。最好联系网站主机,让他们调查,因为他们可以使用错误日志。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26740827

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档