AJAX发布到PHP返回500内部错误
问题描述:
我有一个问题,当AJAX请求返回500内部服务器错误时,代码在运行MAMP的本地机器上正常工作,但只要我将它移动到另一个服务器它给出了500错误。AJAX发布到PHP返回500内部错误
我已经看到,一些人有过类似的问题,但大多数的情况下都导致了他们的代码错别字,这个代码完全适用于甲基苯丙胺预期。
任何意见,将不胜感激
感谢
// 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);
}
?>
答
我发现了错误的根源,init.php在包含一些短标签的db_connection和ldap_connection文件中启用,使短标签/添加长标签可解决问题。
感谢大家的帮助。
答
问题可以在这两个服务器上的PHP版本的区别,我想你正在使用some.outdated功能。 500内部错误是服务器端的错误不是客户端
答
试图配置自定义uploadifive脚本时,我有这个问题。该解决方案将其移到我自己的服务器,它工作正常。你最好联系的虚拟主机提供商,并要求他们进行调查,因为他们可以使用错误日志。
+0
感谢莱昂,我已经试过这两个内部服务器和托管一个外部,检查所有的日志,但没有找到任何其他错误或细节。 – 2014-11-05 09:19:30
检查你的日志然后。 – 2014-11-04 17:03:14
你确定,你不活跃的PHP或Apache模块在本地服务器上,你错过了它活跃在其他服务器上? – ekans 2014-11-04 17:03:27