Ajax ログイン フォームを備えた Bootstrap モーダルがあります。エラーを表示し、 login.phpからの結果が header('Location: index.php');
私は次のように結果を処理します。
var hr = new XMLHttpRequest();
// Set content type header information for sending url encoded variables in the request
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
// Access the onreadystatechange event for the XMLHttpRequest object
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
document.getElementById("status").innerHTML = return_data;
}
}
問題は、ログインが成功し、header('Location: index.php');
応答index.phpが で開かれている場合div.status
です。
PHPヘッダーをjavascriptのリダイレクトに変換する簡単な方法はありますか?