在IE中,使用Ajax时,我最多只能向服务器发送请求7次 [英] In IE, I can only send request to server 7 times maximum when using ajax

查看:121
本文介绍了在IE中,使用Ajax时,我最多只能向服务器发送请求7次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将带有7个选择"标签的ajax添加到Web应用程序中,在其中选择一个选项将使用相关信息填充以下选择"标签.其中一些标签还可以显示另一组单选按钮或复选框.总共可以向服务器发出10个以上的请求,直到获得所需的产品为止. 除了在IE中向服务器的请求被限制为7次之外,其他所有浏览器都可以正常运行,除非您刷新浏览器以重新启动,否则对服务器的请求被限制为7次.我什至试图禁用缓存,但是仍然出现相同的问题...

为什么IE会胡说八道?

这是进行服务器-客户端对话的ajax代码:

function updateAvailableAttributes()
{
var xmlhttp;
var form = document.forms["orderDefinition"];
form.elements["formChangeRequest"].value = "true";
var processingMsgBox = $("#waitingMsgOverlay, #waitingMsgBox, #waitingMsg, #waitingMsgParag");
var map = document.getElementById("OrderMap");

if(window.XMLHttpRequest) 
{// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
}
else 
{// code for IE6 and below
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange = function()
{
    switch(xmlhttp.readyState)
    {
        case 1:
            map.disableApplication();
            processingMsgBox.show();
            break;
        case 4:
            if(xmlhttp.status == 200)
            {
                $('#usercontent .sleeve .toprow').html(xmlhttp.responseText);
                applyValidation();
                browserScrollManagement();
                $("#toolpanel").height($("#orderMap").height());
                inputBtnHighlightSelection();
            }
            else
            {
                sessionTimedOut();
            }

            $("#toolpanel").height($("#orderMap").height());
            map.enableApplication();
            processingMsgBox.hide();
            break;          
    }
}

var parameters = $("form#orderDefinition").serialize();
xmlhttp.open("POST", "ajax/possibleValues.html", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", parameters.length);
xmlhttp.setRequestHeader("Cache-Control", "no-cache");
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(parameters);
}

解决方案

HTTP规范建议修改注册表以仅出于测试目的增加它. >

I added ajax to a web application with 7 'select' tags, in which selecting an option would populate the following 'select' tags with the related information. And some of these tags can also show another set of radio buttons or checkboxes. In all, you can make more than 10 requests to the server until you get your desired product. All work fine in major browsers except in IE, where the request to the server are limited to 7 times and then nothing happens any more until you refresh the browser to start again. I even tried to disable the cache, but still the same problem occured...

Why is IE doing this nonsense?

This is the ajax code doing the server-client talking:

function updateAvailableAttributes()
{
var xmlhttp;
var form = document.forms["orderDefinition"];
form.elements["formChangeRequest"].value = "true";
var processingMsgBox = $("#waitingMsgOverlay, #waitingMsgBox, #waitingMsg, #waitingMsgParag");
var map = document.getElementById("OrderMap");

if(window.XMLHttpRequest) 
{// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
}
else 
{// code for IE6 and below
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange = function()
{
    switch(xmlhttp.readyState)
    {
        case 1:
            map.disableApplication();
            processingMsgBox.show();
            break;
        case 4:
            if(xmlhttp.status == 200)
            {
                $('#usercontent .sleeve .toprow').html(xmlhttp.responseText);
                applyValidation();
                browserScrollManagement();
                $("#toolpanel").height($("#orderMap").height());
                inputBtnHighlightSelection();
            }
            else
            {
                sessionTimedOut();
            }

            $("#toolpanel").height($("#orderMap").height());
            map.enableApplication();
            processingMsgBox.hide();
            break;          
    }
}

var parameters = $("form#orderDefinition").serialize();
xmlhttp.open("POST", "ajax/possibleValues.html", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", parameters.length);
xmlhttp.setRequestHeader("Cache-Control", "no-cache");
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(parameters);
}

解决方案

The HTTP spec recommends that simultaneous connections to a web server must be limited. The limit is lower for IE7 than it is for other browsers. Modify the registry to increase it for testing purposes only.

这篇关于在IE中,使用Ajax时,我最多只能向服务器发送请求7次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆