Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Post或iFrame时,Internet Explorer文件传输接收行重复_Javascript_Html_Iframe - Fatal编程技术网

Javascript 使用Post或iFrame时,Internet Explorer文件传输接收行重复

Javascript 使用Post或iFrame时,Internet Explorer文件传输接收行重复,javascript,html,iframe,Javascript,Html,Iframe,我需要将一个文件从一台计算机发送到一个嵌入式服务器,出于测试目的,将输出发送到超级终端,以查看接收到的内容。如果我们在F12开发工具“网络”上查看计算机,正文通常是正确的,但有时第3行是第2行的副本。在服务器端,在整个传输过程中重复接收到的线路。出于测试目的,此文件为: $A80000032W18%L6C3100D8 $A8000009EW18%LC31600D8 $A8000010AW18%LC31600D8 $A80000176W18%L532F00D8 $A800001E2W18%L22A

我需要将一个文件从一台计算机发送到一个嵌入式服务器,出于测试目的,将输出发送到超级终端,以查看接收到的内容。如果我们在F12开发工具“网络”上查看计算机,正文通常是正确的,但有时第3行是第2行的副本。在服务器端,在整个传输过程中重复接收到的线路。出于测试目的,此文件为:

$A80000032W18%L6C3100D8
$A8000009EW18%LC31600D8
$A8000010AW18%LC31600D8
$A80000176W18%L532F00D8
$A800001E2W18%L22A200D8
$A800002BAW18%L393700D8
$A80000326W18%LE77600D8
$A80000392W18%L5E1900D8
$A800003FEW18%L488600D8
$A8000046AW18%LC77300D8
$A800004D6W18%L904500D8
$A80000542W18%L9F1800D8
$A800005AEW18%L76D400D8
$AEND
有什么建议吗?这种传输可以在Chrome和Firefox上正常工作,但不能在IE和Edge上正常工作。


        <!DOCTYPE html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>MS-Sedco Intersector Server</title>
        <link href="toplevel.css" rel="stylesheet" type="text/css" />

        </head>
        <body>


        <form name=connect >
        <pre>




                <input id="ConnType" type="submit" name=misce onclick="connecting()" value="Connect to Radar" size="2"> 
            <input id="ConnStatus" type="hidden" name=Conn value="*DA;" size="2">
        </pre>
        </form>
        <pre>
            <input type="file" onchange='readText(this)' size="2">
        </pre>

        <pre>

            <input type="button" onclick="program_boot()" value="Program" size="2">
        </pre>

        <pre>

            <div id=BootStatus> </div>   <div id=BootAddress> </div>  <div id=b_test> </div>
        </pre>


        <form name=RTimeout>
        <input type="hidden" name=misce value="RTimeout" size="2">
        </form>

        <form id="ie-fix" name="ie-fix" action="RadarBootLoader.htm" method="POST" target="booter-loader">
          <input type="hidden" id="dataIE" name="" />
        </form>
        <iframe src="" id="boot-loader" name="boot-loader" style="display:none" width="100%" height="600"></iframe>

        </body>

        <script language="JavaScript">
        //////////////////////////////////////////////////////////////////////////////////////
        // Variables global to script
        //////////////////////////////////////////////////////////////////////////////////////
        var Temp_id;
        var txt;
        var etime;
        var index;
        var bootindex;
        var output;
        var address;
        var done = 0;
        var lastlineindex;
        var prog_state = 0;
        var sendout;
        var reader = new FileReader();
        var interval;

        if ( document.getElementById("ConnStatus").value == 1 )
        {
           document.getElementById('BootStatus').innerHTML= "   Radar Boot Connected";
        }


        function readText(that){

                    if(that.files && that.files[0]){
                        reader.onload = function (e) {  
                            output=e.target.result;

                            //process text to show only lines with "@":             
                            //output=output.split("\n").filter(/./.test, /\@/).join("\n");
                            output=output.split("\n")
                            document.getElementById('BootStatus').innerHTML= output;
                            sendout = output[0];
                        };//end onload()
                        reader.readAsText(that.files[0]);
                    }//end if html5 filelist support
        }

        function alertContents(httpRequest){
            if (httpRequest.readyState == 4){
                // everything is good, the response is received
                if ((httpRequest.status == 200) || (httpRequest.status == 0)){
                txt = httpRequest.responseText;
                document.getElementById('BootStatus').innerHTML = httpRequest.responseText;
                if ( (httpRequest.responseText).indexOf("Load Complete") > -1 )
                {
                   prog_state = 0;
                   if ( done )
                   {
                      //done = 0;
                  //bootindex = 0;
                  clearInterval(etime);
                      document.getElementById('BootStatus').innerHTML = "   Program Finished !!!";
                   }
                   else
                   {
                  //clearInterval(etime);
                      //etime = setTimeout( "timeout()", 1);
                      //document.getElementById('BootStatus').innerHTML = " Program Radar Flash Memory";
                      bootindex++;
                  sendout = output[bootindex];
                          if ( (output[bootindex]).indexOf("END") > -1)
                  {
                     done = 1;
                  }
                          else if ( (output[bootindex]).indexOf("$A") > -1)
                  {
                     address = "0x" + (output[bootindex]).substr(2, 8);
                         document.getElementById('BootAddress').innerHTML= "    " + address;          
                  }
                  //console.log(sendout);

                  if (window.XMLHttpRequest) {
                    send_with_ajax('RadarBootLoader.htm');
                  } else {
                    // Here is the IE fix test code
                    var iframe = document.getElementById("boot-loader");
                    var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;

                    document.getElementById("dataIE").value = sendout;
                    document.getElementById("ie-fix").submit();
                    interval = setInterval(iframe_loaded, 2000);
                  }
                   }
                }
                //alert(bootindex);
                    //alert( "The response was: " + httpRequest.status + httpRequest.responseText);
                //alert( (httpRequest.responseText).indexOf("bindex") ); 
                //alert(document.getElementById("BootInd").value);
                }else{
                    alert('There was a problem with the request. ' + httpRequest.status + httpRequest.responseText);
                }
            }
        }

        function iframe_loaded() {
          var iframe = document.getElementById("boot-loader");
          var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
          var httpRequest = {
            readyState: 4,
            status: 200,
            responseText: "Load Complete"
          };

          console.log(iframeDoc.readyState);
          if (iframeDoc.readyState == "complete") {
            clearInterval(interval);
            alertContents(httpRequest);
          }
        }

        function send_with_ajax(url)
        {
            var http_request = false;

                if (window.XMLHttpRequest)
            { // Mozilla, Safari,...
                    http_request = new XMLHttpRequest();
                        if (http_request.overrideMimeType)
                {
                            //http_request.overrideMimeType('text/xml');
                        }
                }
            else if (window.ActiveXObject)
            { // IE
                 try {
                            http_request = new ActiveXObject("text/xml");
                     }
                     catch(e){
                   try
                   {
                            http_request = new ActiveXObject("text/xml");
                           }
                   catch (e)
                   {
                            try
                    {
                                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                            }
                    catch (e) {}
                          }
                  }
                }

                if (!http_request)
            {
                    alert('Giving up :( Cannot create an XMLHTTP instance');
                        return false;
                }

                document.getElementById('b_test').innerHTML = bootindex;

            if (window.XMLHttpRequest) {
              http_request.onreadystatechange = function() { alertContents(http_request); };
                  http_request.open('POST', url, true);
              http_request.setRequestHeader('Content-type', 'multipart/form-data');
              http_request.setRequestHeader('Content-Encoding', "gzip");
                  http_request.send(sendout);
            } else {
              iframe_loaded();
            }
        }


        function connecting()
        {
           document.getElementById('BootStatus').innerHTML= "   Connecting Radar Boot Loader";
        }

        function program_boot()
        {
           document.getElementById('BootStatus').innerHTML= "   Waiting Radar Echo";
           etime = setTimeout( "timeout()", 10000);
           prog_state = 1;
           send_with_ajax('RadarBootLoader.htm');
        }

        function timeout()
        {
           if ( prog_state == 1 )
           {
              done = 0;
              bootindex = 0;
              alert("Can not Program Flash Memory !!");
              document.getElementById('BootStatus').innerHTML= " ";
              clearInterval(etime);
              document.RTimeout.submit();
           }
           /*else
           {
              clearInterval(etime);
              send_with_ajax('RadarBootLoader.htm');
              document.getElementById('b_test').innerHTML = bootindex;
              //etime = setTimeout( "timeout()", 10);
           }*/
        }

        //////////////////////////////////////////////////////////////////////////////////////
        // Infinite loop with delay
        //////////////////////////////////////////////////////////////////////////////////////
        function loop()
        {
           bootindex = 0;
        }


        //////////////////////////////////////////////////////////////////////////////////////
        // Run
        //////////////////////////////////////////////////////////////////////////////////////
        window.onload=loop;


        </script>
        </html>
MS Sedco Intersector服务器 ////////////////////////////////////////////////////////////////////////////////////// //脚本的全局变量 ////////////////////////////////////////////////////////////////////////////////////// var Temp_id; var-txt; 变量时间; var指数; var指数; var输出; var地址; var done=0; var指数; var prog_state=0; var输出; var reader=new FileReader(); var区间; if(document.getElementById(“ConnStatus”).value==1) { document.getElementById('BootStatus').innerHTML=“雷达引导连接”; } 函数readText(即){ if(that.files&&that.files[0]){ reader.onload=函数(e){ 输出=e.target.result; //处理文本以仅显示带“@”的行: //output=output.split(“\n”).filter(/./.test,/\@/).join(“\n”); 输出=输出。拆分(“\n”) document.getElementById('BootStatus')。innerHTML=output; 输出=输出[0]; };//结束onload() reader.readAsText(即.files[0]); }//如果html5文件列表支持,则结束 } 函数alertContents(httpRequest){ if(httpRequest.readyState==4){ //一切都很好,收到了回复 if((httpRequest.status==200)| |(httpRequest.status==0)){ txt=httpRequest.responseText; document.getElementById('BootStatus').innerHTML=httpRequest.responseText; if((httpRequest.responseText).indexOf(“加载完成”)>-1) { 程序状态=0; 如果(完成) { //完成=0; //bootindex=0; 间隔时间; document.getElementById('BootStatus').innerHTML=“程序完成!!!”; } 其他的 { //间隔时间; //etime=setTimeout(“timeout()”,1); //document.getElementById('BootStatus').innerHTML=“程序雷达闪存”; bootindex++; sendout=输出[引导索引]; if((输出[引导索引]).indexOf(“结束”)>-1) { 完成=1; } else if((输出[bootindex]).indexOf($A”)>-1) { address=“0x”+(输出[bootdex]).substr(2,8); document.getElementById('BootAddress')。innerHTML=“”+地址; } //控制台日志(发送); if(window.XMLHttpRequest){ 用ajax发送_('RadarBootLoader.htm'); }否则{ //这是IE修复测试代码 var iframe=document.getElementById(“引导加载程序”); var iframeDoc=iframe.contentDocument | | iframe.contentWindow.document; document.getElementById(“dataIE”).value=sendout; document.getElementById(“ie修复”).submit(); 间隔=设置间隔(如果加载帧,2000年); } } } //警报(引导索引); //警报(“响应为:”+httpRequest.status+httpRequest.responseText); //警报((httpRequest.responseText.indexOf(“bindex”)); //警报(document.getElementById(“BootInd”).value); }否则{ 警报(“请求有问题”。+httpRequest.status+httpRequest.responseText); } } } 函数iframe_loaded(){ var iframe=document.getElementById(“引导加载程序”); var iframeDoc=iframe.contentDocument | | iframe.contentWindow.document; var httpRequest={ 重新编制日期:4, 现状:200, responseText:“加载完成” }; console.log(iframeDoc.readyState); 如果(iframeDoc.readyState==“完成”){ 间隔时间; alertContents(httpRequest); } } 函数send_with_ajax(url) { var http_request=false; if(window.XMLHttpRequest) {//Mozilla、Safari,。。。 http_请求=新的XMLHttpRequest(); if(http_请求.overrideMimeType) { //http_请求。重写emimetype('text/xml'); } } else if(window.ActiveXObject) {