更新页面时mysql的变化? [英] Updating page when mysql changes?

查看:95
本文介绍了更新页面时mysql的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面的网站上,该工作原理类似于一个反向拍卖。它有向下穿过根据拍卖是多长一个javascript倒计时。当它击中零拍卖结束,页面刷新。

I have got a page on a website, that works similar to a reverse auction. It has a javascript countdown timer that runs down depending on how long the auction is. When it hits zero the auction ends and page refreshes.

所有的作品像一个梦,但问题是,如果申办放在我想要的页面刷新显示该出价,并更新许多其他因素。

All works like a dream, but the problem is if a bid is put in I wanted the page to refresh displaying that bid, and update many other elements.

该网站目前通过检查通过快速的PHP文件做到这一点,当闪光灯注意到的改变刷新页面。这是好的,但我们不会删除闪存,仅使用JavaScript,所以我们没有运行在iPhone / iPad和其他移动设备的网站的任何问题。

The site currently does this by checking a php file via flash and when flash notices the change refreshes the page. This is fine, but we wont to remove flash and only use javascript so we don't have any problems running the site on iPhones/iPads and other mobile devices.

所以,过了长篇大论集结起来,我需要一个解决方案,是这个AJAX或其他方式,任何帮助更受欢迎这里...

So, after a long winded build-up I need a solution, be this AJAX or another method, any help more than welcome here...

在此先感谢

推荐答案

您应该呈现出价量创建一个div ID。而使用jQuery更新通过AJAX调用量完成如下。

You should create a div id for showing the bid amount. And use jQuery to update the amount via AJAX call as done below.

setTimeout('update_amount()', 1000);

function update_amount(){
        var amt = $("#amount").html();
        $.post('ajax_file.php?a='+amt, function(data){
        if(data!=''){
            $('#amount').html(data);                
        }

下面在页面上显示的当前值存储到的 AMT 的。那么这个值是通过AJAX传递到PHP文件作为后。你将不得不做的程序来检查MySQL表的金额是否有变化,如果变化只是呼应了新的金额在该PHP文件。这一数额将在量DIV ID在当前页面进行更新。

Here the current value displayed in the page is stored into amt. Then this value is passed to the php file via AJAX as post. You will have to do the procedures to check whether the amount has changed in the mySql table and if changed just echo the new amount in that php file. That amount will be updated in the amount div id in the current page.

这篇关于更新页面时mysql的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆