Wait until previous .append() is complete

后端 未结 9 982
情话喂你
情话喂你 2020-12-09 19:14

How can we make append wait until the previous append is complete. I am appending huge amount of data so the present append should check if the pre

9条回答
  •  执念已碎
    2020-12-09 20:02

    The below solution is working on all the browsers especially IE6. The response time in Firefox is 10 sec, but in IE6 it is 2 min 30 sec.

    $('#printall1').click(function() {
        $('#fourElementsonly').empty();
        var cleartable = 0;
        var maxlimit = 0;
        var presentarraycount = 0;
    
        $.post("/PortalUserReport/getjunkdata", null, function(response, status) {
            var report = eval(response);// we have 6000 records in the report now
            var totalRecordsCount = report.length; // count = 6000 
            var totalRecordsCountfortheLoop = totalRecordsCount;
            var arraycount = Math.ceil(totalRecordsCount / 1000);
            var reports = new Array(arraycount); // reports[6]
            for (var i = 0; i < arraycount; i++) {
                $('#fourElementsonly').append('
    '); } reports[presentarraycount] = ""; $.each(report, function(x) { if (cleartable == 0) { for (var i = 0; i < arraycount; i++) { $('#Portal_User_elements' + i).empty(); } cleartable++; } if (recordnumber <= totalRecordsCountfortheLoop) { reports[presentarraycount] += " " + recordnumber + " Name :" + report[x].FirstName + " UserName :" + report[x].UserName + " Company : " + report[x].Company + " "; reports[presentarraycount] += " Registration Date : User CN : " + report[x].UserCN + " Status: " + report[x].Status + " "; reports[presentarraycount] += " User Privilege : " + report[x].Privileges + " "; maxlimit++; if (maxlimit == 1000) { presentarraycount++; reports[presentarraycount] = ""; maxlimit = 0; } } recordnumber++; }); for (var i = 0; i < arraycount; i++) { $('#Portal_User_elements' + i).append(reports[i]); } }); });

提交回复
热议问题