[jQuery] Long running AJax request blocking the other ajax requests

[jQuery] Long running AJax request blocking the other ajax requests


Hi,
I execute a long task by an Ajax request, and at the same time I would like
to display the percentage of this task every second. The problem is that the
percentage will not display as the first request is slowing down the others.
Though ... they say Ajax is synchronous ...
The code is quite easy to get:
refreshPercentage();
[...]
$.ajax({
    type: "GET",
    dataType: "json",
    url: "<?php echo $this->baseUrl; ?>/admin/link-checker", // long task,
synchronous
    success: function(data) {
        if(data.success) ;
        else alert(data.msg);
    },
    error: function(xhr, status, ex) {alert('Request failed.');}
});
[...]
function refreshPercentage() { // every second, get the percentage done and
display it
    $.ajax({
        type: "GET",
        dataType: "json",
        async: false,
        url: "<?php echo $this->baseUrl; ?>/admin/link-checker/get-percentage",
        success: function(data) {
            if(data.success) $('span#percentage').html(data.nb);
            else alert(data.msg);
        },
        error: function(xhr, status, ex) {alert('Request failed.');}
    });
    setTimeout("refreshPercentage()",1000);
}
[...]
What's the problem ? What's the workaround, if any ?
Thank you for your help!
--
View this message in context: http://www.nabble.com/Long-running-AJax-request-blocking-the-other-ajax-requests-tp25072487s27240p25072487.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.