Image and Content Flickering When Call Getdata() by signal R in asp.net

Viewed 35

This Will Help you to check every time that a new value is loaded, then execute row push. It will hold continuous flickering

var pcode = '', empcode = '' , count = 0;

    function getData() {               
         
            var $tbl = $('#tbl');
            $.ajax({
                url: 'index.aspx/GetData',                 
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                type: "POST",
                success: function (data) {
                    
                    if (data.d.length > 0) {
                        var newdata = data.d;
                        pcode = newdata[0].emp_code;
                        if (pcode != empcode || pcode == '') {
                            count++;
                            $tbl.empty();
                            //$tbl.append(' <tr><th>ID</th><th>Name</th><th>Desig</th><th>Depart</th><th>Punch Time</th><th>Status</th></tr>');
                            var EMP_NAME = '', DESIG_NAME = '', emp_code = '', DEPT_NAME = '', punch_time = '', Status = '';
                            var chk = '';
                            var rows = [];
                            for (var i = 0; i < newdata.length; i++) {
                                empcode = newdata[i].emp_code;
                                EMP_NAME = newdata[i].EMP_NAME;
                                DESIG_NAME = newdata[i].DESIG_NAME;
                                emp_code = newdata[i].emp_code;
                                DEPT_NAME = newdata[i].DEPT_NAME;
                                punch_time = newdata[i].punch_time;
                                Status = newdata[i].Status;
                                rows.push('<}
                            $tbl.append(rows.join(''));
                        }
                    }
                }
            });                          
        }
0 Answers
Related