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 8158987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:46:53+00:00 2026-06-06T17:46:53+00:00

I have a jQuery dialog that appears and loads an external page. In that

  • 0

I have a jQuery dialog that appears and loads an external page. In that page i am running a setInterval() function that queries my server continuously every 1 second (AJAX). The problem is that when i close the dialog, the setInterval doesn’t stop running.

here is the code for the dialog:

var theUrl = 'someUrl';

var popUp = document.createElement('div');

$(popUp).dialog({
        width: 400,
        height: 270,
        title: "Some Title",
        autoOpen: true,
        resizable:false,
        close: function(ev, ui) {
                    $(this).dialog('destroy');
               },
        modal: true,
        open: function() { 
                    $(this).load(theUrl);
              }
});    

I tried calling $(this).dialog('destroy') and $(this).remove() and document.body.removeChild(popUp) on close. nothing worked. is there anyway to ‘unload’ the loaded page?

  • 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-06T17:46:56+00:00Added an answer on June 6, 2026 at 5:46 pm

    setInterval returns a handler that you can pass to clearInterval to stop the function from running. Here’s a basic example of how it works.

    var handler = setInterval(function() {}, 2000);
    clearInterval(handler);
    

    For your example you’d want to call clearInterval in the close method of the ui.dialog.

    Docs:

    setInterval – https://developer.mozilla.org/en/window.setInterval

    clearInterval – https://developer.mozilla.org/en/DOM/window.clearInterval

    Edit

    You will not be able to call clearInterval without the stored handler from setInterval, therefore if the call to setInterval is in another script the only way you’re going to capture the handler is to override window.setInterval itself.

    $(function() {
        var originalSetInterval = window.setInterval;
        var handlers = [];
    
        window.setInterval = function() {
            handlers.push(arguments[0]);
            originalSetInterval(arguments);
        };
    
        $('whatever').dialog({
            close: function() {
                for (var i = 0; i < handlers.length; i++) {
                    clearInterval(handlers[i]);
                }
                handlers = [];
            }
        });
    });
    

    Note that the code to override window.setInterval must come before including the <script> tag to bring in the external file. Also this approach will clear all interval functions whenever clearInterval is called, therefore this is not ideal, but it’s the only way you’re going to accomplish this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery dialog which loads an external php page. All is working
On my web page I have a button that opens a modal jQuery dialog.
When creating or editing object sin my table, I have a jquery dialog that
I have a jQuery UI Dialog that gets displayed when specific elements are clicked.
I have a jquery modal dialog that displays a partial view. The partial view
I have a small form that contains a jQuery UI dialog to ask for
I have the following Jquery that returns values from a dialog Box and fills
I have a modal dialog plugin written in jquery, that binds to the click
I have a fairly basic dialog maker for jquery that works in 2 out
I have an asp.net usercontrol that contains a jQuery UI Dialog Control. All works

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.