为了账号安全,请及时绑定邮箱和手机立即绑定

同步的 XMLHttpRequest 已不推荐使用 , 那怎么实现同步操作呢 ?

同步的 XMLHttpRequest 已不推荐使用 , 那怎么实现同步操作呢 ?

hhhzihao2 2016-05-16 17:03:45
$(function () {   $("img[id^='isshow']").click(function() {     var $id = $(this).attr('id').replace('isshow', '');     if ($(this).attr('src').match('yes')) {       var $isshow = 'yes';       var $newisshow = 'no';     } else {       var $isshow = 'no';       var $newisshow = 'yes';     }     var $data = 0;     $.ajax({       type: 'post',       url: '__URL__/isshowPro',       // async : false,       data: {'id':$id, 'isshow':$newisshow},       success: function (data) {         $data = data;       }     });     if ($data == 1) {       $(this).attr('src', function () {           return $(this).attr('src').replace($isshow, $newisshow);       });     }   })   }) 如果 // async : false , 打开 , 火狐会出现这个警告 : "主线程中同步的 XMLHttpRequest 已不推荐使用,因其对终端用户的用户体验存在负面影响。更多帮助请见 http://xhr.spec.whatwg.org/" 问 : 如果 async : true , 如何同步地实现这段代码 ? if ($data == 1) {       $(this).attr('src', function () {           return $(this).attr('src').replace($isshow, $newisshow);       });
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 16454 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信