Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8947001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:38:17+00:00 2026-06-15T12:38:17+00:00

I have the following poll() function: var pollTimeout = 5000; (function poll(){ setTimeout(function(){ $.ajax({

  • 0

I have the following poll() function:

var pollTimeout = 5000;
(function poll(){
   setTimeout(function(){
      $.ajax({ url: "/ajax/livedata.php", success: function(data){
         if (data[0] == 'success'){
            // i'm doing some irrelevant updating here
         }
         poll();
      }, dataType: "json"});
   }, pollTimeout);
})();

It’s being executed every 5 seconds and everything works fine.

However, how can I execute this function manually? For example, I need to execute it here:

$("#status-update-form textarea").keyup(function(e){
   if (e.keyCode == '13'){
      var status = $(this).val();
      $.get("/ajax/update-status.php", { 'status' : status },
         function(data){
            $("#status-update-form textarea").val('').blur();
            // <-- I need to execute the poll here, so that
            // the status is updated immediatelly after it's
            // submitted, not when the poll fires seconds later
         },'json'
      );
   }
});

Any idea how can I do this? If I try to fire poll(), it says the function doesn’t exist.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:38:19+00:00Added an answer on June 15, 2026 at 12:38 pm

    Convert your poll to a regular function

    var pollTimeout = 5000;
    
    function poll(timeout){
       return setTimeout(function(){
          $.ajax({ url: "/ajax/livedata.php", success: function(data){
             if (data[0] == 'success'){
                // i'm doing some irrelevant updating here
             }
             poll();
          }, dataType: "json"});
       }, timeout);
    }
    
    
    $("#status-update-form textarea").keyup(function(e){
       if (e.keyCode == '13'){
          var status = $(this).val();
          $.get("/ajax/update-status.php", { 'status' : status },
             function(data){
                $("#status-update-form textarea").val('').blur();
                poll(0);
             },'json'
          );
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: XService.start = function() { setInterval(XService.poll(), XService.pollInterval); } This works
I have written the following jQuery for autorefreshing a page containing a poll (to
I have the following code in my application: using (var database = new Database())
I have created a following program in which I wish to poll on the
I have the following in several of my models: The Poll.rb for instance: def
I have a controller that generates the following json data: [ { title: Option
I have the following models : class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField(auto_now_add=True)
I have a model that looks like the following: class Loves(models.Model): poll = models.ForeignKey(Poll)
in get_poll function in following Poll model: class Poll_model extends CI_Model { public function
I have the following piece of code for a very simple PHP polling script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.