首页 > ajax同步接口报错,谁来看下?

ajax同步接口报错,谁来看下?

错误提示:

Synchronous XMLHttpRequest on the main thread is deprecated because of
its detrimental effects to the end user's experience. For more help,
check https://xhr.spec.whatwg.org/.

ajax代码:

 function facXq(){
      $.ajax({
      type:"get"
      ,url: '../../snippet/pduDemand.html'
      ,data:''
       ,success:function(msg){
        $('#fac-content').html(msg);
        }
       ,error:function(XMLHttpRequest, textStatus, thrownError){
        alert("异步发生错误!");
        }
    });
  }
    

   $('#fac-crd').on('click',function(){
      facXq();
});

如果改成-post-请求就报错,还有网上看到说如果一定要实现get方式,就要封装一个worker,这个具体怎么做比较对?


这好像不是报错,是个 warning 吧?

提醒你别用同步,改成异步请求吧?


至少说报什么错误才好回答啊


你的这个业务流程直接用异步好了。同步请求放在主线程中会造成浏览器阻塞。如果确实需要同步请求那么一定要放在worker中

【热门文章】
【热门文章】