$(function(){ showLoadImg(); var size = parseInt("<%=scModels.size()%>"); var scUrlArr = "<%=scUrlBuffer.toString()%>".split(","); var scVersionArr = "<%=scVersionBuffer.toString()%>".split(","); var scNameArr = "<%=scNameBuffer.toString()%>".split(","); var scURIArr = "<%=scURIBuffer.toString()%>".split(","); var scIDArr = "<%=scIDBuffer.toString()%>".split(","); var browerVersionListArr = "<%=browerVersionListBuffer.toString()%>".split("$$"); for(var i=0;i<size;i++){ var scUrl=scUrlArr[i]; var scVersion=scVersionArr[i]; var scName=scNameArr[i]; var scUri=scURIArr[i]; var scID=scIDArr[i]; var browerVersionList = browerVersionListArr[i]; $.ajax({ url:"<%=Config.getHomeURL()%>/UpdateServiceComponentVersionAction.do?operation=checkVersion",dataType:"JSON",async:true,type:"POST",data:{ "scUrl":scUrl,"scVersion":scVersion,"scName":scName,"scUri":scUri,"browerVersionList":browerVersionList,"scID":scID,"requestID":i },success:function(result){ var scVersion1 = result.scVersion; var scName1 = result.scName; var scUrl1 = result.scUrl; var scID1 = result.scID; var reuqestID1 = parseInt(result.requestID); if(scVersion1!="noNeedToUpdateCurrentSC"){ var newTr = $("<tr class='EvenOrOddRow'></tr>"); var td1 = $("<td nowrap></td>").html("<input type='checkBox' value="+scID1+" name='singleItem'>"); var td2 = $("<td nowrap></td>").html(scName1+""); var td3 = $("<td nowrap></td>").html(scUrl1+""); var td4 = $("<td nowrap></td>").html(scVersion1+""); newTr.append(td1).append(td2).append(td3).append(td4); $($(".listView").find("tbody")).append(newTr); } if(reuqestID1==size-1){ hideLoadImg(); if($("[name='singleItem']").length>0){ $("#dataDisplayTb").removeAttr("style"); $("#submitTb").removeAttr("style"); $("#tipsTb").find("tr").find("td").html('<ecv:message path="core.common/servicecomponents.records"/>'); }else{ $("#tipsTb").find("tr").find("td").html('<ecv:message path="core.common/servicecomponents.norecords"/>'); } $("#tipsTb").removeAttr("style"); } } }); } });
listNeedUpdateSCSVersionInfo.jsp页面在页面dom节点load之前要请求处理一批数据得到一个数据集合list,然后在页面body里面循环展示list中的数据。
由于这批数据的处理时间较长,很有可能就因为会因为阻止了页面里面dom元素的渲染而导致页面timeout。
可行的解决办法是先让页面load出来,然后在页面load完后异步发送ajax请求去完成数据处理。但是如果发一次ajax请求去后台处理数据,也有可能因为数据批量大耗时长而导致ajax请求timeout,所以可以针对这一批数据,可以每一条发送一次ajax请求,然后将返回结果动态append到页面。
原文链接:https://www.f2er.com/ajax/163633.html