0

I have a python script that's doing around 8 or 9 specific steps. These steps are being logged in a file. For web GUI to display status change, or error messages, I am using the script belowjquery PeriodicalUpdater plugin. I need the program to run simultaneously so that as the value in the file changes,it gets polled and displayed.

Please find my jquery code below. Note the url "/primary_call/" takes around 2 and half minutes to execute. Problem is async :false is not working. The browser waits for 2.5 minutes, and then gets into the next level. I tried in Firefox and Chrome and it gives the same result.

When I call the URL of another browser tab, it works perfectly, but I am unable to run both script components simultaneously, when I try calling from the same page. What should I do so that the browser initiates "/primary_call/", which runs a Python script in the background, at the same time moving ahead to the portion called PeriodicUpdate.

$(document).ready(function()
$.ajax({
type: 'GET', // Or any other HTTP Verb (Method)
url: '/primary_call/',
async: false,
success: function(r){
    return false;
},
error: function(e){
}
});

$.PeriodicalUpdater({
                url : '/static/12.txt',
                method: 'post',
                maxTimeout: 6000,

           },
            function(data){
                var myHtml = data + ' <br />';
                $('#results').append(myHtml);
        });


    })
0

1 Answer 1

3

Setting async:false means you are making the process synchronous, so the browser will hang on it until it is finished -- it can't move on to your other method. Removing that option will make the call asynchronous (which it is by default, as it should be) at which point the browser will initialize each ajax call in a separate thread.

In short, remove async:false.

Sign up to request clarification or add additional context in comments.

1 Comment

api.jquery.com/jQuery.ajax/#jQuery-ajax-settings Take a look at the docs. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false is deprecated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.