gpt4 book ai didi

javascript - ajax 在 IE 8 中非常慢,但在 firefox 和 chrome 中非常快

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:35:48 24 4
gpt4 key购买 nike

有很多类似的帖子,但没有一个完全符合我的需要。所以我被迫创建一个帖子。

名称列表显示在 jsp 页面上。当您将鼠标悬停在一个名称上时,我会执行一个 ajax 调用以在工具提示弹出窗口中显示该名称的详细信息。

用户将使用 IE8。在 IE8 中做这个简单的事情大约需要 5 秒,而在 Firefox 和 chrome 中它会立即发生。

我还注意到,随着显示的名称数量的增加或减少,响应时间在 IE8 中也是如此。

我怎样才能使它在 IE8 中更快?

jsp页面

<td onmouseover ="showDetails('${origin }')">
<a href="#"><c:out value="${origin}"></c:out><span id="info"></span></a>
</td>

javascript函数

function showDetails(stop){
var xmlHttpRequest;
if(window.XMLHttpRequest){
xmlHttpRequest = new XMLHttpRequest();
}else{
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpRequest.onreadystatechange=function(){
if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){
document.getElementById("info").innerHTML = xmlHttpRequest.responseText;
}
}
xmlHttpRequest.open("GET", "showStopsInfoPopup.do?stop="+stop, true);
xmlHttpRequest.send();
}

最佳答案

试试这个。

function showDetails(stop){
var t1 = new Date().getTime();
var xmlHttpRequest;
if(window.XMLHttpRequest){
xmlHttpRequest = new XMLHttpRequest();
}else{
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpRequest.onreadystatechange=function(){
if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){
alert("Call took " + (new Date().getTime() - t1) + " milliseconds");
document.getElementById("info").innerHTML = xmlHttpRequest.responseText;
}
}
xmlHttpRequest.open("GET", "showStopsInfoPopup.do?stop="+stop, true);
xmlHttpRequest.send();
}

您可能会看到调用速度同样快,但在 IE8 中慢的是响应的后续呈现。

如果您确认这一点,那么问题就是关于响应文本中的内容。

关于javascript - ajax 在 IE 8 中非常慢,但在 firefox 和 chrome 中非常快,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13090993/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com