在AJAX请求返回500个内部服务器错误时,我遇到了一个问题,代码在运行MAMP的本地机器上运行良好,但是一旦我将它移到另一台服务器上,它就会产生500错误。
我看到有些人也有类似的问题,但大多数情况下都会导致他们的代码输入错误,这段代码在MAMP上的工作原理与预期完全一样。
如有任何建议,将不胜感激。
谢谢
// 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);
}
?>发布于 2014-11-05 10:36:17
我已经找到了错误的根源,init.php提取了一个包含一些短标记的db_connection和ldap_connection文件,启用了短标记/添加了长标记解决了这个问题。
谢谢大家的帮助。
发布于 2014-11-04 17:11:58
问题可能与两台服务器上的php版本不同,我猜您正在使用some.outdated函数。500内部错误是服务器端错误,而不是客户端错误。
发布于 2014-11-04 17:26:56
在试图配置自定义上载5脚本时,我遇到了这个问题。解决方案是把它移到我自己的服务器上,它运行得很好。最好联系网站主机,让他们调查,因为他们可以使用错误日志。
https://stackoverflow.com/questions/26740827
复制相似问题