【发布时间】:2008-10-28 21:24:42
【问题描述】:
我正在编写一个应用程序,并尝试将简单的 AJAX 功能绑定到其中。它在 Mozilla Firefox 中运行良好,但在 Internet Explorer 中存在一个有趣的错误:每个链接只能单击一次。浏览器必须完全重新启动,简单地重新加载页面是行不通的。我写了一个 very simple example application 来演示这一点。
Javascript 转载如下:
var xmlHttp = new XMLHttpRequest();
/*
item: the object clicked on
type: the type of action to perform (one of 'image','text' or 'blurb'
*/
function select(item,type)
{
//Deselect the previously selected 'selected' object
if(document.getElementById('selected')!=null)
{
document.getElementById('selected').id = '';
}
//reselect the new selcted object
item.id = 'selected';
//get the appropriate page
if(type=='image')
xmlHttp.open("GET","image.php");
else if (type=='text')
xmlHttp.open("GET","textbox.php");
else if(type=='blurb')
xmlHttp.open("GET","blurb.php");
xmlHttp.send(null);
xmlHttp.onreadystatechange = catchResponse;
return false;
}
function catchResponse()
{
if(xmlHttp.readyState == 4)
{
document.getElementById("page").innerHTML=xmlHttp.responseText;
}
return false;
}
任何帮助将不胜感激。
【问题讨论】:
标签: javascript ajax internet-explorer