#2
tang6882009-12-31 12:08
|
最近干一个活的时候,用到了AJAX,但是特郁闷啊,遇到了一个让人头疼的问题,在ie8下没有问题,可是在ie6或者ie7的情况下,xmlhttp.send(),就会出错,错误提示:The download of the specified resource has failed。不知道有没有大虾遇到过这样的问题,而且,我在家里的电脑上,firefox下也是可以正常的,但在办公室,firefox也没有效果,并且firefox的版本是一样的,都是中国版!恳求大虾们指点啊!下面是代码:
function postXmlHttp(url,paramList) //发送xmlhttp函数定义
{
createXMLHttpRequest(); //调用创建xmlhttp函数
var btype=getOs(); //调用判断浏览器函数
xmlHttp.onreadystatechange = (btype!="Firefox")?(xmlHttpHandlerStateChange):(xmlHttpHandlerStateChange());//请求状态改变事件触发handleStateChange功能
xmlHttp.open("POST",url,false);
// xmlHttp.setRequestHeader("content-length",paramList.length);
xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
// try{
xmlHttp.send(paramList);
// }catch (e) {alert(e);}
xmlHttp.onreadystatechange = (btype!="Firefox")?(xmlHttpHandlerStateChange):(xmlHttpHandlerStateChange()); //这句重复的,是为了挡住firefox,让在firefox下再执行,为了兼容firefox
}
function createXMLHttpRequest()
{
try{
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
alert("你的浏览器不支持 AJAX!");
return false;
}
}
}
}
调用postXmlHttp函数:
function WorkpieceFilter_Enter()
{
var _CustomerName_Filter=document.getElementById("CustomerName_Filter").value;
var _ImgNum_Filter=document.getElementById("ImgNum_Filter").value;
var _WorkpieceNum_Filter=document.getElementById("WorkpieceNum_Filter").value;
var _WorkpieceMaterial_Filter=document.getElementById("WorkpieceMaterial_Filter").value;
var _WorkpieceProcess_Filter=document.getElementById("WorkpieceProcess_Filter").value;
var paramList="CustomerName="+_CustomerName_Filter+"&ImgNum="+_ImgNum_Filter+"&WorkpieceNum="+_WorkpieceNum_Filter+"&WorkpieceMaterial="+_WorkpieceMaterial_Filter+"&WorkpieceProcess="+_WorkpieceProcess_Filter;
postXmlHttp("XmlHttpHandler.aspx?Type=Contect_WorkpieceFilter",paramList);
}