2014-11-04 2 views
0

AJAX 요청이 500 내부 서버 오류를 반환하는 순간 문제가 발생합니다. 코드는 MAMP를 실행하는 로컬 컴퓨터에서 정상적으로 작동하지만 다른 곳으로 이동하자 마자 문제가 발생합니다. 서버는 500 오류를 제공합니다.AJAX Post to PHP returns 500 내부 오류

일부 사람들은 비슷한 문제를 겪고있는 것으로 나타 났지만, 대부분의 경우 코드에서 오타가 발생했습니다.이 코드는 MAMP에서 예상대로 작동합니다.

어떤 조언을 크게 두 서버에서 PHP 버전과의 차이에있을 수

감사

// 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); 
} 

?> 
+2

로그를 확인하십시오. –

+0

로컬 서버에서 php 또는 apache 모듈을 활성화하지 않았으며 다른 서버에서 활성화하지 않으셨습니까? – ekans

답변

0

init.php가 짧은 태그를 포함하는 db_connection 및 ldap_connection 파일을 가져 와서 짧은 태그 추가/긴 태그 추가로 문제를 해결했습니다.

귀하의 도움에 감사드립니다.

1

문제를 주시면 감사하겠습니다, 난 당신이 some.outdated 기능을 사용하는 것 같아요. 500 내부 오류는 클라이언트 측이 아닌 서버 측 오류입니다.

0

사용자 정의 uploadifive 스크립트를 구성하려고 할 때이 문제가있었습니다. 해결책은 내 서버로 옮겨서 잘 작동했습니다. 웹 호스트에 문의하는 것이 가장 좋으며 오류 로그를 사용할 수 있으므로 조사를 요청하는 것이 가장 좋습니다.

+0

감사합니다. Leon, 저는 두 개의 내부 서버에서 이것을 시도했으며 하나의 외부 호스트가 모든 로그를 검사했으며 다른 오류나 세부 사항을 찾을 수 없었습니다. –