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

  • SEARCH
  • Home
  • 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 6383943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:42:46+00:00 2026-05-25T02:42:46+00:00

This is my code: // Refresh feeds, but ONLY when you are NOT typing

  • 0

This is my code:

// Refresh feeds, but ONLY when you are NOT typing
var refreshId = setInterval(function() {
    $("#load-feeds").load('/actions/loadfeed.php?randval='+ Math.random());
}, 9000);
$.ajaxSetup({ cache: false });

I’m working on a kind of “wall” like Facebook where you can comment on each other’s posts. The wall automatically refreshes with AJAX (every 9 seconds), but when you’re typing and the textfield is focused it removes the focus and the content of the textbox after the page refreshed.

How can I make it only refresh when you’re NOT typing and make it stop when you’re typing. Thanks! I’ve looked everywhere and tried everything, but no luck.

  • 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-05-25T02:42:47+00:00Added an answer on May 25, 2026 at 2:42 am

    I suppose you have an input box like this:

    <input type="text" id="input-box" ... />
    

    All you have to do is mantain a global variable than says if this input has the focus:

    var isTyping = false;
    $("#input-box").focus(function() {
        isTyping = true;
    });
    $("#input-box").blur(function() {
        isTyping = false;
    });
    

    then you just have to check this variable before to allow the update:

    // Refresh feeds, but ONLY when you are NOT typing
    var refreshId = setInterval(function() {
        if (!isTyping) {
            $("#load-feeds").load('/actions/loadfeed.php?randval='+ Math.random());
    }, 9000);
        }
    $.ajaxSetup({ cache: false });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: $('#page-refresh').click( function() { $.ajax({ url: /page1.php, cache: false, dataType: html,
This code always works, even in different browsers: function fooCheck() { alert(internalFoo()); // We
This code does not seem to compile, I just need to write something to
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
This code function LoadContent(Id) { alert('Controls/Network/NetworkDetail.aspx?' + rnd() + '&CtlId=' + Id); $.get('Controls/Network/NetworkDetail.aspx?' +
I have this code : <?php session_start(); echo .$_SESSION['eventnum'].; $urlRefresh = testremot.php; header(Refresh: 5;
Is there another code or a better one for this code: window.onload = refresh();
Inspecting what facebook is doing in my navigator, I see this code: for (;;);{t:refresh}
Im using this code to refresh the parent window and close the popup window..Is
I need to refresh the page using jquery? I am using location.reload(true); This code

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.