对于固定Ajax调用IE浏览器12030重复性错误 [英] Fixing the IE 12030 repeatability bug for Ajax calls
问题描述
我只是环路我的Ajax调用,直到12030错误消失。报告错误,作为一个bug 这里
有谁知道是否有更好的修复...因为这需要时间循环。我读这是一个已知的问题与IE浏览器,它产生间歇性的错误12030作为阿贾克斯的状态。
VAR阿贾克斯= {
createAjaxObject:函数()
{
VAR请求;
尝试
{
要求=新XMLHtt prequest();
}
赶上(错误)
{
尝试
{
要求=新的ActiveXObject(MSXML2.XMLHTTP);
}
赶上(错误)
{
尝试
{
要求=新的ActiveXObject(Microsoft.XMLHTTP);
}
赶上(错误)
{
请求= FALSE;
}
}
}
返回请求;
},
useAjaxObject:功能(路径,参数,ajax_func,html_div)
{
VAR对象=新Ajax.createAjaxObject();
object.open(POST,路径,真实);
object.setRequestHeader(内容型,应用程序/ x-WWW的形式urlen codeD);
object.setRequestHeader(内容长度,param.length);
object.setRequestHeader(连接,关闭);
object.onreadystatechange =功能()
{
如果(this.readyState === 4)
{
如果(this.status === 200)
{
ajax_func(this.responseText,html_div);
}
其他
{
Ajax.repeatUseAjaxObject(路径,参数,ajax_func,html_div);
返回false;
}
}
};
object.send(参数);
返回true;
},
repeatUseAjaxObject:功能(路径,参数,ajax_func,html_div)
{
VAR状态=假,
数= 1;
而(州===假放;&安培; COUNT< = 5)
{
状态= Ajax.useAjaxObject(路径,参数,ajax_func,html_div);
如果(计数!== 1)
{
警报(Ajax对象使用失败');
}
算上++;
}
返回的状态;
}
我有这个同样的问题,我找到了解决方法,只要AJAX请求是异步的。对于我的作品
解决的办法是包装在AJAX调用一个的setTimeout
为0的延迟调用。
这似乎工作的时间100%的我。
我也验证了我的同事之一的12030错误仍然出现在Internet Explorer 9中,也是如此。
<咆哮>所以比利G和公司认为合适的为我们提供了新的新城的接口,但它们不能被人打扰,以解决他们的所有Web程序员必须支持&LT浏览器; /咆哮>
I just loop my Ajax call until the 12030 error goes away. The error is reported as a bug here
Does anyone know if there is a better fix...as this takes up time to loop. I read this was a known issue with IE that it intermittently produces 12030 errors as that Ajax status.
var Ajax = {
createAjaxObject: function()
{
var request;
try
{
request = new XMLHttpRequest();
}
catch(error)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(error)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(error)
{
request = false;
}
}
}
return request;
},
useAjaxObject: function( path, param, ajax_func, html_div )
{
var object = new Ajax.createAjaxObject();
object.open( "POST", path, true );
object.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
object.setRequestHeader( "Content-length", param.length );
object.setRequestHeader( "Connection", "close" );
object.onreadystatechange = function()
{
if( this.readyState === 4 )
{
if( this.status === 200 )
{
ajax_func( this.responseText, html_div );
}
else
{
Ajax.repeatUseAjaxObject( path, param, ajax_func, html_div );
return false;
}
}
};
object.send( param );
return true;
},
repeatUseAjaxObject: function( path, param, ajax_func, html_div )
{
var state = false,
count = 1;
while(state === false && count <= 5)
{
state = Ajax.useAjaxObject( path, param, ajax_func, html_div );
if( count !== 1 )
{
alert( 'Ajax Object Use Failed ');
}
count++;
}
return state;
}
I have this same problem, and I found a solution that works for me as long as the AJAX request is asynchronous.
The solution is to wrap the AJAX call in a setTimeout
call with a delay of 0.
This seems to work 100% of the time for me.
I also verified with one of my co-workers that the 12030 error still occurs in Internet Explorer 9, as well.
<rant>So Billy G and company see fit to provide us with the new "Metro" interface, but they can't be bothered to fix their browser that all web programmers must support</rant>
这篇关于对于固定Ajax调用IE浏览器12030重复性错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!