donoworuq450547191 2013-06-20 16:13
浏览 43
已采纳

在php中发送参数以触发页面刷新1x

I'm trying to make an app that triggers different content on a webpage based on the button pressed in the app. I need to be able to send a parameter to tell the server to refresh the video, image, and text when a button in the app is pressed....right now it changes the video/image but you have to hit the refresh button in the browser to see the new content...

Everything I've tried refreshes at an interval and it reloads the video/content repeatedly...

Currently i have 3 entries in a mysql db, and one of the fields is "active". When I press a button in the app, it sets all of the row's "active" field to 0, then it sets the record with the id of the button pressed to active=1.

In my display.php page I have it check the mysql for all records with active=1, and it works great, but I need to somehow tell it to trigger a refresh when the active record changes in the db....

The webpage will only be run one 1 machine which is running chrome, it's then displayed on a digital billboard, and I want people to be able to trigger the different content by pressing different buttons on their mobile devices...I can't figure out how to communicate with the sedna presenter software to tell it to refresh the page so was hoping to just make the webpage update itself (like with ajax but for video/image) and the sedna simply displays the webpage like a view in MVC pattern.

Would an iframe help?

  • 写回答

1条回答 默认 最新

  • dtvgo28624 2013-06-20 16:45
    关注

    So basically your going to want to add a new php script on the server which looks for the change in your mysql table on the field active (as an aside there is a better way to do this then repeteadly checking though I can't recall how). Then have your javascript function poll this script. using this method again:

      window.setInterval(function(){ /// call your function here }, 100);
    

    Have the php script return a 0 or a 1 to indicate if active has changed. then check this result in your java script if active has changed reload the page with a get request to the display.php script ... if you want some help with the code I can post somethng in a bit... I'm just eating lunch and on a mobile so it will take a bit of time

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大