php ajax dynamic loading data plus (front and rear end without isolation)

 

The company has a maintenance management system for a long time recently to add functionality to customer requirements Display marquee in the center console, but because it is a <meta http-equiv = "refresh" content = "5"> before the system refreshes every 5 seconds a page to refresh the data, so the scroll bar just taken a while will stop and start all over again. How it can not affect the normal operation of the scroll bar when it refresh the data? ajax appeared in my mind, but for ajax, this white basic stay on only heard his tall, I do not know what it is exactly the point, so the Internet to find a little tutorial that he tried to knock a piece of code, watching the norm there are sample code, a wanton mouth evoke arc, he was secretly delighted, 'I can also Well, ha ha', then put the line, see the console a bright red, mouth arc solidification, turned around and is looking forlornly great God next table. Great God only hope that my code glance pointed out my mistake; before and after the end of the "Little Comrade, this system is not separate from you this ajax code before and after the end of the separation, of course, is not working anymore to see brother Lou Liangshou to you. " Then the meal is operating fierce as a tiger, I see it really is not (faint) ratio (faint) Pei (desire) service (sleep), and finally on-line test, everything ok. Later, a little research and found ajax really difficult to imitate God's idea of ​​a large number of other data modules have been replaced with ajax, this code is, the more knocking more addictive ah, ha ha! Next, the code involved in the offer for them to learn ajax, if wrong, welcome criticism.

 

 

php (must be placed prior to the location of the page, or will refresh the entire page infinite)

<?php


$ProType = empty($_GET["ProType"]) ? '' : $_GET["ProType"];


if ($ProType=='getList') {


    ?>


<?php

$sql_r = "select dd.*,member.name as bm from dd left join member on member.id=dd.js where dd.status=1 order by dd.jj desc,dd.id asc";
foreach ($dbh->query($sql_r) as $key=> $rs_r) {

    $id = $rs_r["id"];
    $name = stripslashes($rs_r["name"]);
    $cx = stripslashes($rs_r["cx"]);
    $qh = stripslashes($rs_r["qh"]);
    $sl = stripslashes($rs_r["sl"]);
    $stime = stripslashes($rs_r["stime"]);
    $jj = stripslashes($rs_r["jj"]);
    $bm = stripslashes($rs_r["bm"]);
    ?>
    <tr class="cen" <? if($jj==1){echo "style=background:#ff0000;!important;color:#ffffff";}?>>
        <td style="font-size:30px;!important"><?php echo $name;?></td>
        <td style="font-size:30px;!important"><?php echo $cx; ?></td>
        <td style="font-size:30px;!important"><?php echo $qh; ?></td>
        <td style="font-size:30px;!important"><?php echo $sl; ?></td>
        <td style="font-size:30px;!important"><?php echo $stime; ?></td>
        <td style="font-size:30px;!important"><?php echo $bm; ?></td>
    </tr>
<?php }
    exit();
}


?>

 

 

html

<main class="main-cont content mCustomScrollbar" style="padding:0">
        
        <!--开始::结束-->
                     <marquee>我是滚动字幕</marquee>

                            <div class="panel-bd" style="padding:20px">
                                
                        <table class="table table-bordered table-striped table-hover">
                            <thead>
                            <tr>
                                <th style="font-weight:bold;font-size:30px;!important">客户名称</th>
                                <th style="font-weight:bold;font-size:30px;!important">车型</th>
                                <th style="font-weight:bold;font-size:30px;!important">颜色</th>
                                <th style="font-weight:bold;font-size:30px;!important">数量(L)</th>
                                <th style="font-weight:bold;font-size:30px;!important">预计交板时间</th>
                                <th style="font-weight:bold;font-size:30px;!important">>TH</Work Code
                            </tr>
                            </thead>
                            <tbody id="aaa">

                            </tbody>
                        </table>
                        </div>

</main>

 

 

JS (using jQuery framework)

        the console.log ($ ( '# AAA' )); 

        the getList (); 

        the setInterval ( function () {// data once every 5 seconds to refresh 

            the getList (); 

        }, 5000 ) 

        // Get the list of orders 
        function the getList () { 
            .get $ ( 'the getList protype =?', '', function (Data) { 

                $ ( '#aaa' ) .html (Data); 

            }); 
        }

 

Guess you like

Origin www.cnblogs.com/yite/p/11440061.html