数据格式:
--PushEnd
Content-Type: text/plain 5...--PushEnd
Content-Type: text/plain 4...--PushEnd
Content-Type: text/plain 3...--PushEnd
Content-Type: text/plain 2...--PushEnd
Content-Type: text/plain 1...--PushEnd
--PushEnd
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body><script type="text/javascript">
  
var xrequest = ajax();
xrequest.multipart = true;
xrequest.open("GET", "http://localhost:/Push",false);
xrequest.onload = handleContent;
xrequest.send(null);function handleContent(event) {
    var response = xrequest.responseText;
    alert(response);
}function ajax(){
    // 创建兼容不同浏览器的XMLHttpRequest对象
    var xmlHttp;
    // for Firefox
    try{
        xmlHttp=new XMLHttpRequest();
        return xmlHttp;
    }
    // for Internet Explorer
    catch(e){
        try{
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP.6.0");
            return xmlHttp;
        }
        catch(e){
            alert("您的浏览器不支持Ajax!");
            return null;
        }
    }
}
</script></body>
</html>
用以上代码在Mozilla Firefox正常,在IE不能提示,不知道是什么原因?
Msxml2.XMLHTTP.6.0本机有不是Msxml2.XMLHTTP.6.0问题。

解决方案 »

  1.   


    var xrequest = ajax();xrequest.open("GET", "http://localhost:/Push",false);
    xrequest.onreadystatechange = handleContent;
    xrequest.send(null);可以吗?
    好像没有onload事件
      

  2.   

    另外,为了避免版本问题。可以写成xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      

  3.   

    你这个multipart/x-mixed-replace,只有firfox 才支持,其他任何浏览器都不支持