/    Sign up×
Community /Pin to ProfileBookmark

Calling a PHP function with Ajax every 20 secs

Hi,

I have a PHP function and I want an Ajax script which will call the function every 20 secs once the page is loaded. I need to refresh the content of a specific part of my page and I don’t want to use iframe + refresh. I will be glad if you could help.

Regards
Ceyhun

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@Specht08Dec 03.2009 — [CODE]setTimeout(function() {
[yourajaxrequest]
}, 20000);
[/CODE]

Us the Timeout function of Javascript. The unit of the last attribute is milliseconds
Copy linkTweet thisAlerts:
@Specht08Dec 03.2009 — Sorry if forgot that you want to call it every 20 seconds. This would do the trick:
[CODE]
function asd(){
[yourajaxrequest]
setTimeout('asd()', 20000);
}
[/CODE]

Your on load function also contains setTimeout('asd()', 20000);
Copy linkTweet thisAlerts:
@telmessosauthorDec 03.2009 — hi thanks for reply. my ajax request is calling a php function. all I want to do is just calling a PHP function called getcur(). I am a beginner AJAX coder. So please write me in "... For Dummies" style if possible.

Thanks

telmessos
Copy linkTweet thisAlerts:
@Specht08Dec 03.2009 — So you have your ajax request in your javascript. You just need to surround it with my code fragment. And done.
Copy linkTweet thisAlerts:
@telmessosauthorDec 04.2009 — I don't know what ajax script to write. by saying "my ajax script" I meant "I need a script like that". that's the point ?
Copy linkTweet thisAlerts:
@telmessosauthorDec 04.2009 — ok thanks. I'll have look at it. ?
×

Success!

Help @telmessos spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...