我正在编写一个应用程序,想要添加简单的AJAX功能。在Mozilla Firefox中效果很好,在Internet Explorer中有一个有趣的bug:每个链接只能被点击一次。必须完全重新启动浏览器,简单地重新加载页面是行不通的。我编写了一个非常简单的示例应用程序来演示这一点。
以下是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;
}
非常感谢任何帮助。