开发者

PHP:I want to run a function every 30sec's without using a for loop

php has header('refresh:30')

When i'm getting data from a form via post,the array resets on refresh(when i use header-refresh)

I was looking for a setTimeOut(in javascript) sorta tool in php开发者_如何学运维 or a way to persist a variable got from the user(form data) even after a refresh.

-- Php Beginner


...or a way to persist a variable got from the user(form data) even after a refresh.

Try using $_SESSION to keep certain variables. This will allow the variables to be kept even after navigating away to another page. Keep in mind that you must start the session with session_start() before using sessions.

http://www.php.net/manual/en/book.session.php

As to the rest of your question, I'm not exactly sure what you're asking... >_>


You should use

window.onload = setInterval("function_to_refresh_data()",3000) //3000 is interval in milliseconds

Use Ajax response in a div so that only that div refreshes , otherwise the whole page will be refreshed .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜