www.webdeveloper.com
Results 1 to 8 of 8

Thread: Calling a PHP function with Ajax every 20 secs

  1. #1
    Join Date
    Apr 2006
    Posts
    219

    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

  2. #2
    Join Date
    Nov 2009
    Posts
    44
    Code:
    setTimeout(function() {
      [yourajaxrequest]
    }, 20000);
    Us the Timeout function of Javascript. The unit of the last attribute is milliseconds

  3. #3
    Join Date
    Nov 2009
    Posts
    44
    Sorry if forgot that you want to call it every 20 seconds. This would do the trick:
    Code:
    function asd(){
     [yourajaxrequest]
     setTimeout('asd()', 20000);
    }
    Your on load function also contains setTimeout('asd()', 20000);

  4. #4
    Join Date
    Apr 2006
    Posts
    219
    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

  5. #5
    Join Date
    Nov 2009
    Posts
    44
    So you have your ajax request in your javascript. You just need to surround it with my code fragment. And done.

  6. #6
    Join Date
    Apr 2006
    Posts
    219
    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

  7. #7
    Join Date
    Nov 2009
    Posts
    44

  8. #8
    Join Date
    Apr 2006
    Posts
    219
    ok thanks. I'll have look at it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles