js什么情况下会出现阻塞?
高洛峰
高洛峰 2016-10-27 11:01:31
0
1
579

1、警告信息: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/.
2、代码
//添加按妞事件
function addClick(obj){

//判断右侧列表是否已包含该商品 var myid = $(obj).parent().parent().attr("data-id"); var theGoods = $("#tailList").find("tr[data-id='"+myid+"']"); var _th=$(obj).parent().parent(); var datanum = _th.attr('data-id'); var price = parseFloat($("#price_"+datanum).val()); var vipprice = parseFloat($("#vipprice_"+datanum).val()); if(theGoods.length>0){ var theGoodsAmount = $($(theGoods).find(".ct_nnm")[0]).html(); $(obj).parent().parent().find(".ct_nnum").html(parseInt(theGoodsAmount)).removeClass("disnone"); adds2($(obj).parent().find(".readd").children().first(),"price_"+datanum); $(obj).addClass("disnone"); return ; } //校验数量 var num = parseInt($(obj).parent().parent().find(".ct_nnum").text()); var canuseamount = $("td[data-name='canuseamount']",$(obj).parent().parent()).text();//可售数量 var cansale=0; var consumerlinkstock = $("#consumerlinkstock").val(); if(consumerlinkstock=="0"){//关联库存,不能超过库存数量 cansale = parseInt(canuseamount); if(cansale<1){ var msg=""+canuseamount+""; alert(msg,function(){},"warning",false); return; } }else{//未关联库存,默认上限为999 if(num>=999){ alert("",function(){},"warning",false); return; } } //更新到“购物车” $.ajax({ url:"consumerCart.html?goodsno="+$(_th).attr("data-id")+"&amount=1"+"&price="+price,

// data:{"cartgoods.price":price,"cartgoods.totalprice":totalprice,"cartgoods.title":title,"cartgoods.bid":"","cartgoods.goodsid":goodsid,"cartgoods.gsn":gsn,"cartgoods.tid":tid,"cartgoods.direct":direct,"cartgoods.validity":validity},

type:"POST", dataType:"text", async:false, success:function(){}, error:function(){return false;} }); //页面操作 var myrownum = $(".mydetail").length; var str=""+ ""+$('.good-name',_th).text()+""+ ""+price+""+ ""+vipprice+""+ " 1 "+ ""+price+""+ ""+vipprice+""+ ""+ '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ""+ ""; $('.ct_tblst').append(str); _th.find('.ct_nnum').removeClass('disnone'); $(obj).addClass('disnone'); consume();


高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

Antworte allen (1)
三叔

$.ajax中把async:false改为async:true,请使用异步的方式发送请求

    Neueste Downloads
    Mehr>
    Web-Effekte
    Quellcode der Website
    Website-Materialien
    Frontend-Vorlage
    Über uns Haftungsausschluss Sitemap
    Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!