js中的坑

    xiaoxiao2021-03-25  98

    原意:本来想实现投屏点下等待结果后再进行下一步的刷新?结果坑了自己

    原因有两点:

    1

    后台可能一直再链接着让ajax无法等到结果其后果是以后无论再那个浏览器上访问都失败就算后台已经截图并且保存到服务器上都不会获取到

    其请求总是被取消掉了 (主要出在tcp的服务端的长链接没有断掉总卡在accept方法上)

    解决办法

    service = new  ServerSocket(port);  service.setSoTimeout(3000);

    2

    js加了boolean判断 想法是让他们总是进行依次点击当有时flag 没有改为true

    function send(unique, type, x1, y1, x2, y2, text,robotId) {    var path = "${request.pageContext.contextPath}/cust/forscreen!startForScreen.do";     if(robotId){        path+="?robotId="+robotId;     }     if (flag) { flag = false;   $.ajax({      url : path,      data:{'unique':unique,'type':type,'x1':x1,'y1':y1,'x2':x2,'y2':y2,'text':text},      cache : false,      async : true,      type : "GET",      dataType : 'text',      success : function (result){        oEn.src="";          oEn.src = result;        flag = true;       },       error:function(result){          flag = true;       },      complete:function(){         flag = true;        }    });  } };

    解决办法在每次点击从新有设置为true

    function beginForScreen(robotId){    unique = new Date().getTime();    document.getElementById("myimage22").src="images/open.gif"; document.getElementById('f_screen').style.display = "block"; flag = true; send(unique,'home',0,0,0,0,null,robotId); }

    转载请注明原文地址: https://ju.6miu.com/read-24211.html

    最新回复(0)