【问题标题】:Ajax call not updating first timeAjax 调用第一次没有更新
【发布时间】:2013-09-28 07:49:10
【问题描述】:

我使用 Ajax 调用来显示数据和更新数据。 Ajax 调用运行良好,但不是一次更新。服务器中的数据库更新良好。对于 UI 部分,它没有更新。

使用 Ajax 调用

    $('#loginbutt').click(function(){
        $.post('data.php',{action: "update"},function(res){
        $('#result').html(res);
            });
var servertime = $("#timer1").text();
 var dataString = 'current_time='+ servertime;
                     $.ajax({
                             type: "POST",
                             url: "inset_intime.php",
                             data:dataString ,
                             cache: true,
                             beforeSend: function(html) {
                             document.getElementById("lastfive").innerHTML = ''; 
                            },
                             success: function(html){
                                $("#lastfive").append(html);  
                               }
                      });

        });

它正在更新数据 .php 但不更新 inset_time.php。数据正在插入好 inti 服务器。但用户界面没有更新。在 data.php 我给出了插入数据的插入查询。在 inset_time.php 中,我给出了用于显示数据的选择查询。但是为什么不是在我点击loginbutt的时候。

【问题讨论】:

  • 能否请您添加您的html代码,以便我可以帮助您。
  • 什么是dataString..?
  • @Dipesh Parmar PLZ 现在检查。我更新了我的代码

标签: php ajax call


【解决方案1】:

试试这个

$(document).ready(function(){

$('#loginbutt').live('click',function(){
    $.post('data.php',{action: "update"},function(res){
    $('#result').html(res);
        });
var servertime = $("#timer1").text();
 var dataString = 'current_time='+ servertime;
                 $.ajax({
                         type: "POST",
                         url: "inset_intime.php",
                         data:dataString ,
                         cache: true,
                         beforeSend: function(html) {
                         document.getElementById("lastfive").innerHTML = ''; 
                        },
                         success: function(html){
                            $("#lastfive").append(html);  
                           }
                  });

    });

});

【讨论】:

  • 我已经使用 document.ready 但我没有保留在这里.. 仅在 dat 中我保留了此功能
猜你喜欢
  • 2016-10-30
  • 2012-02-02
  • 2018-02-03
  • 2019-03-26
  • 2015-02-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多