【问题标题】:How to refresh element in cakephp using jquery如何使用 jquery 刷新 cakephp 中的元素
【发布时间】:2013-06-06 05:09:29
【问题描述】:
<div class="mytabelement">
     <?php     
        if($newstatus[0]['users']['status'] == 'complete'){
          echo $this -> Form -> postLink(__('update'), array(
    'controller'=>'orders','action' => 'user_satus','admin'=>false), array(
    'class' => 'uiBtn uiBtnBlue','id'=>'runloGc','title' => 'Run Logic'), 
    __('Are you sure you want update user?'));
    <?php } ?>
</div>

上面是我网站每个页面上的元素数据,我只需要每 2 分钟刷新一次这个元素,而不刷新页面..?有没有可能请帮忙..!!

【问题讨论】:

    标签: jquery cakephp


    【解决方案1】:

    使用 jquery

    setTimeout(function(){
        $.post(url,data,function(data){
            $(".mytabelement").html(data);
        });
    },2*60*1000);
    

    【讨论】:

      【解决方案2】:

      这里我只是举个例子。

      您可以根据需要将其更改为响应htmlJson

      希望您熟悉 ajax 数据类型。

           <script>
                      $(document).ready(function(){
                          Notifications();  // this will call only one time thats first body load time 
                          setInterval("Notifications()", 2*60*1000);  // this will call each 5000ms
                          //60000
                      });
                      function Notifications(){
      var url = "http://example.com/user/list"
                          //alert("Notify");
                          $.ajax({
                              url: url,
                              success: function(data){
                                  var test=eval(data);
                                  $("#dii").empty();
                                  for(i=0;i<test.length;i++){
      
                                      $("#dii").append("<b>"+test[i]['name']+"</b>");
                                      $("#dii").append(":");
                                      $("#dii").append(test[i]['post']);
                                      $("#dii").append("<br />");
      
                                  }
                              }
                          }); 
                      }
                  </script>
      

      还可以为您的控制器操作设置您的逻辑并输出数据。

      如果我能帮助你更多,请告诉我

      【讨论】:

      • 如果我能帮助你,请告诉我更多。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-03
      • 1970-01-01
      • 1970-01-01
      • 2011-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多