【问题标题】:jquery datatables : load real time progress barjquery datatables:加载实时进度条
【发布时间】:2016-05-06 06:43:42
【问题描述】:

正常的 ajax 实时进度条是这样加载的,

$.ajax({
xhr: function() {
                var xhr = new window.XMLHttpRequest();
                xhr.upload.addEventListener("progress", function(e) {
                    var pro = (e.loaded / e.total) * 100;
                    $('.progress-bar-anim').css('width', pro + '%').attr('aria-valuenow', pro);
                }, false);
                return xhr;
            },
            type: "POST",
            dataType: 'json',
            url: "data.php",
            data: {"username": username, "password": password},
            success: function(msg) {
                if (msg.status == 'success') {
                    window.location = "dashboard.php"
                } else {
                    hide_progress();                 
                }
            }
        });

我想在收到服务器响应的同时在 jquery 数据表 中加载实时进度条。我应该怎么做?

【问题讨论】:

    标签: javascript jquery ajax datatables jqxhr


    【解决方案1】:

    在你的成功方法中创建表:

    function getData() {
        $.ajax({
          url : 'example.com',
          type: 'GET',
          success : handleData
        })
    }
    
    function handleData(data) {
        table = $('#table').DataTable( {
                "data": data,
                ....
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-08
      • 1970-01-01
      • 1970-01-01
      • 2011-10-18
      • 2014-02-06
      • 2015-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多