|
|
|
ช่วยด้วยครับ ติดปัญหาเกี่ยวกับ ajax คือว่า HttPRequest.responseText ใน IE มีค่าตรงกับทีส่งมาครับ แต่ใน Firefox ,Chrome ไม่มีค่าครับ |
|
|
|
|
|
|
|
Code (PHP)
function login() {
var HttPRequest = false;
if (window.XMLHttpRequest ) { // Mozilla, Safari,...
var HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var usr = document.getElementById('usr').value;
var psw = document.getElementById('psw').value;
var type = document.getElementById('type').options.value;
var url = 'login.php';
var pmeters = 'usr='+usr+'&psw='+psw+'&type='+type;
//alert(pmeters);
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 4) // Return Request
{
alert(HttPRequest.responseText);
if(HttPRequest.responseText=="admin"){
window.location="admin.php";
}else if(HttPRequest.responseText=="manager"){
window.location="welcome.php";
}else if(HttPRequest.responseText=="depleader"){
window.location="welcome.php";
}else if(HttPRequest.responseText=="grpleader"){
window.location="welcome.php";
}else if(HttPRequest.responseText=="user"){
window.location="welcome.php";
}else if(HttPRequest.responseText=="0"){
document.getElementById('psw').value='';
alert('Username or Password incorrect.');
}else if(HttPRequest.responseText=="2"){
document.getElementById('psw').value='';
alert('Your account has been disable.');
}else{
document.getElementById('psw').value='';
alert('Access denied for your account');
}
}
}
}
Tag : PHP, HTML/CSS, JavaScript, Ajax, CakePHP, JAVA
|
|
|
|
|
|
Date :
2012-07-14 13:27:27 |
By :
Newuser |
View :
1331 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยนไปใช้ jQuery กับ Ajax ดูครับ จะได้ไม่มีปัญหาเรื่อง Web Browser
|
|
|
|
|
Date :
2012-07-14 20:57:04 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|