【发布时间】:2008-12-08 23:54:44
【问题描述】:
我有一个使用 jQuery ajax 在页面加载后将成员计数加载到 divs 的 asp 页面。
它在 FireFox 中运行良好,并且适用于具有少量组的客户端。
对于拥有许多组 (500+) 的少数客户端,我在 IE 中遇到错误。 ajax 调用似乎是同步运行的,因为在每个 ajax 调用返回之前,点击事件不会注册。
对于大多数客户端来说,一系列 ajax 请求只是 1 个请求。它仅被分解为具有大量组的客户端的多个请求。
现在,我看到了如果在加载 DOM 后添加链接,$("a").click 函数未绑定的错误。不起作用的链接不是由 AJAX 加载的,它们不属于此类别。
这是伪代码:
ready()
{
// count the number of groups that this user has, adding the ids to a list
if( count < 50 )
{
runAjax();
}
else
{
// this calls the ajax request on groups of 50 ids
// it pauses briefly after each request by using setTimeout to call the next
runAjaxRecursively();
}
}
这里是ajax请求:
// run the HTTPRequest
$.ajax({
async: true,
type: "POST",
url: "emailcatcount.asp?idList="+idList,
data: "idList="+idList,
dataType: "html",
success: function(html) { // blah blah blah }
});
无论如何,代码运行良好,因此请将任何错误视为拼写错误。唯一的问题是,在 IE 中,直到每个 ajax 调用都返回后才会触发点击事件。
有谁知道为什么会发生这种情况?请注意,我将 async 设置为 true。
这和jQuery的ready事件在IE中的处理方式有什么关系吗?
我很困惑,并且在这方面花了几天时间,所以任何想法都值得赞赏。
【问题讨论】:
标签: jquery ajax internet-explorer events