jQuery AJAX div重装在每个刷新间隔后增加div的大小

时间:2019-04-08 12:41:53

标签: javascript php jquery ajax laravel

我正在laravel + voyager上做一个项目,在一个页面中,我想从数据库中重新加载数据而无需手动刷新页面,所以我使用了jQuery / AJAX,重新加载有效,但是在每个重新加载间隔上,它都会改变我div并移动我正在刷新的div之外的导航栏和侧边栏。有人可以帮忙吗?

我以为这可能是因为jQuery版本,但是我尝试了多个版本,但结果仍然相同。

页面(blade.php):

import xlwt


cols = [
    ['Feedstock', 'None', 'Naphtha', '5.00000', '2005', 'Y'],
    ['Feedstock', 'None', 'Naphtha', '0.00000', '2006', 'Y'],
    ['Feedstock', 'None', 'Naphtha', '0.00000', '2007', 'Y'],
    ['Building Blocks', 'Olefins', 'Ethylene', '5.00000', '2005', 'Y'],
    ['Building Blocks', 'Olefins', 'Ethylene', '5.00000', '2006', 'Y'],
]

res = {}
for c1, c2, c3, c4, c5, c6 in cols:
    res_key = "{}-{}-{}".format(c1, c2, c3)
    year_key = "{}-{}".format(c5, c6)
    years = {"year": year_key, "value": c4}
    res.setdefault(res_key, []).append(years)

title = ["" for _ in range(3)]
_lst = [title]
is_first = True
for info, years in res.items():
    rows = [item if not item == "None" else "" for item in info.split("-")]
    for item in years:
        year = item["year"]
        value = int(float(item["value"]))
        rows.append(value)
        if is_first:
            title.append(year)
    is_first = False
    _lst.append(rows)

book = xlwt.Workbook(encoding='utf8')
sheet = book.add_sheet('untitled', cell_overwrite_ok=True)

for row, rowdata in enumerate(_lst):
    for col, val in enumerate(rowdata):
        sheet.write(row, col, val)
book.save("test.xls")

感谢您的帮助。 图片: before

after

1 个答案:

答案 0 :(得分:0)

Removed $this.unwrap()

@extends('voyager::master')
@section('page_title', 'ACD Status')
@section('page_header')
<h1 class="page-title">
    <i class="voyager-phone"></i>
    ACD Status
</h1>
@stop
@section('content')
<div class="page-content edit-add container-fluid" id=>
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-bordered">
                <div id="tables">
                    <div id="reload">
                        --Data Here--
                    </div>  
                </div>
                <script language="javascript" type="text/javascript">
                    var timeout = setTimeout(reloadStatus, 5000);
                    var i=0;
                    function reloadStatus(){
                        $('#tables').load('/admin/acd-status #reload',function(){
                            timeout = setTimeout(reloadStatus, 5000);
                        });
                        console.log(i++);
                    }
                </script>
            </div>
        </div>
    </div>
</div>
@stop