问题使用AJAX调用在IE6和IE7 - 我再问同样的问题,因为我没有得到任何解决方案之前 [英] problem using AJAX call in IE6 and IE7 -- I am asking the same question again, cause i did not get any solution before
问题描述
我有这个代码,它在FireFox,chrome和IE8工作正常,但它不工作在IE6和IE7。
I have this code, which is working fine in FireFox, chrome and IE8 but is it not working on IE6 and IE7.
function GetXmlHttpObject() {
//var xmlHttp = null;
try {
xmlHttp = new XMLHttpRequest();
} catch (e) {
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function login()
{
alert("Entered Login()");
var url="http://server.com/ALUauth.php";
xmlhttp.onreadystatechange=statechangedLogin;
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
}
function statechangedLogin()
{
if(xmlhttp.readyState==4)
{
alert("Entered State Changed Login");
if (xmlhttp.responseText=="Please <a href=http://server.com/ALUauth.php?login>login</a>")
{
document.getElementById("ALUauth").innerHTML=xmlhttp.responseText;
}
else
{
GetEmailId();
}
}
}
function GetEmailId()
{
alert("Entered GetEmailId()");
var url="http://server.com/GetPostEmail.php";
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=statechangedLogin2;
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
}
function statechangedLogin2()
{
if(xmlhttp.readyState==4)
{
alert("Enter State Changed Login 2");
if(xmlhttp.responseText=="Login again")
{
window.location="http://server.com/profile.html";
}
}
}
任何其他浏览器除了IE6和7输出显示我所有的警报框从开始: - 输入登录() - 输入状态更改登录 - 输入GetEmailId() - 输入状态更改的登录2
When I run the code in any other browser except for IE6 and 7 the output shows me all the alert boxes starting from: - Entered Login() - Entered State Changed Login - Entered GetEmailId() - Enter State Changed Login 2
,然后窗口位置更改为 http://server.com/profile.html
and then the window location changes to http://server.com/profile.html
但是当我在IE 6或7上运行同样的东西时,代码不会进入statechangedLogin2(),所以我得到的只有警报:
but when I run the same thing on IE 6 or 7, the code does not go into the statechangedLogin2(), and so the only alerts I get here are:
* Entered Login()
* Entered State Changed Login
* Entered GetEmailId()
我无法弄清楚为什么会出现此问题。为什么会发生,我应该改变什么?该项目在包括IE8在内的其他浏览器上正常工作。
I am unable to figure out why this issue is occuring. Why is it happening, and what should I change? The project is working absolutely fine on other browsers include IE8.
有人可以帮我解决这个问题。
Can some one help me figure this issue of mine.
推荐答案
您好,很抱歉再次发布我的问题。但我没有得到任何解决方案,所以我试图这样做。你对我很抱歉。
Hello i am sorry to post my question again. but i was not getting any solution there so i tried to do this. thou i am sorry about it.
无论如何,我可以在我老板的帮助下解决这个问题。
Anyways i was able to solve the situation with the help of my boss.
所有我做的是给GetEmailId函数自己的会话。类似这样:
all i did was to give GetEmailId function its own session. something like this:
function GetEmailId()
function GetEmailId()
{
alert ); xmlhttpTwo = GetXmlHttpObject()var url =http://server.com/GetPostEmail.php; url = url +& sid =+ Math.random(); xmlhttpTwo.onreadystatechange = statechangedLogin2; xmlhttpTwo.open(GET,url,true); xmlhttpTwo.send(null); }
{ alert("Entered GetEmailId()"); xmlhttpTwo=GetXmlHttpObject() var url="http://server.com/GetPostEmail.php"; url=url+"&sid="+Math.random(); xmlhttpTwo.onreadystatechange=statechangedLogin2; xmlhttpTwo.open("GET", url, true); xmlhttpTwo.send(null); }
我试过这个,它在IE 6 n 7 ...:)工作绝对正常:
I tried this and it works absolutely fine on IE 6 n 7 ... :)
Zeeshan
这篇关于问题使用AJAX调用在IE6和IE7 - 我再问同样的问题,因为我没有得到任何解决方案之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!