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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:03:05+00:00 2026-06-14T18:03:05+00:00

I have a web application based on Django. I use the Scrapy Crawler to

  • 0

I have a web application based on Django. I use the Scrapy Crawler to crawl webpages. My goal, at the moment, is to be able to control the crawler from within a webpage using jQuery and AJAX requests.

My theoretical setup is the following:

  • On the webpage, I have a button. When I click the button, the crawler is started on the server-side.
  • Once the crawler has started, I periodically send AJAX GET requests to the server using window.setInterval to find out how many webpages have been crawled so far.
  • Once the crawler has finished, the GET requests should stop by using window.clearInterval.

These are the relevant lines from my current code:

$(document).ready(function() {

    // This variable will hold the ID returned by setInterval
    var monitorCrawlerId;

    $startCrawlerButton.on('click', function(event) {

        // This function should be run periodically using setInterval
        var monitorCrawler = function() {

            $.ajax({

                type: 'GET',
                url: '/monitor_crawler/',
                // ...
                success: function(response) {

                    // if the server sends the message that the crawler
                    // has stopped, use clearInterval to stop executing this function
                    if (response.crawler_status == 'finished') {

                        clearInterval(monitorCrawlerId);

                    }

                } 

            });

        };

        // Here I send an AJAX POST request to the server to start the crawler
        $.ajax({

            type: 'POST',
            url: '/start_crawler/',
            // ...
            success: function(response) {

                // If the form that the button belongs to validates correctly,
                // call setInterval with the function monitorCrawler defined above
                if (response.validation_status == 'success') {

                    monitorCrawlerId = setInterval('monitorCrawler()', 10000);

                }

            }

        });

    });
});

The problem: When I execute this code, I get this in Firefox’s web console:

ReferenceError: monitorCrawler is not defined

The strange thing, however, is that the function monitorCrawler gets periodically executed anyway. But with every execution, I get the same error message again. If I put monitorCrawler outside of $startCrawlerButton.on() I still get the same errors. How can I resolve this? Since I’m a JavaScript newbie, any help is appreciated. Thank you very much!

  • 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-14T18:03:06+00:00Added an answer on June 14, 2026 at 6:03 pm

    setInterval, when first parameter is string, resolves in the global (window) context. You can give it a variable pointing to the function to be called or even:

    setInterval(function(){monitorCrawler();}, 10000);
    

    this will create a closure where local variable monitorCrawler will still exist when interval fires.

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

Sidebar

Related Questions

I have typical web application based on PHP, HTML, and javascript. From an HTML
We have a requirement to control access to our SaaS based web application based
We have a old Web Based application supported on browsers from IE6 to IE8
We have a web based application in production built using django. It is deployed
I have a web application based on the sharp-architecture framework. It actually use NHibernate
I have a Django-based web application that is required to send a confirmation email
In our web application (django based, with solr backend) we have some checkboxes with
I have a django-based web application that is a mixture of jQuery and several
I have one legacy web application based on struts2 (primarily using annotation). While debugging
I have a web-based application which is very highly reliant on jquery / javascript,

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.