How to get rid of the 'progress' cursor?

Posted by Ivan on Stack Overflow See other posts from Stack Overflow or by Ivan
Published on 2012-06-04T16:00:59Z Indexed on 2012/06/04 16:41 UTC
Read the original article Hit count: 239

Filed under:
|
|

I have an interval that launches an AJAX call to check if there is any update for the page (I imagine that it's similar to the mechanism used by Facebook or StackExchange to check for new notifications). The problem is that this call changes the cursor to the 'progress' or 'busy' cursor (visual problem) and disables to option to click on links (functional problem).

I suppose both problems are related. How can get rid of this effect or at least minimize the consequences?

Some code:

setInterval(function() {
    try {
        var mid = $($("ul#alert-messages li.regular")[0]).attr('ref');
        call_ajax('/load_alerts', {num:0, id:mid}, function (data) {
            if (data.ok) {
                for (var i=0; i<data.result.length; i++) {
                    // ....
                }
                // ...
            }
        }, function() {},          // Do not show any error for this!!
        false);                    // Do not change cursor!
    } catch (e) {}
}, 15000);

function call_ajax(url, data, fnSuccess, fnError) {
    $.ajax({
        'url': url,
        'type': 'POST',
        'data': data,
        'dataType': "json",
        'success' : function(data) {
            if (fnSuccess) {
                fnSuccess(data);
            } else {
                if (typeof data.msg != 'undefined') {
                    topBar(data.msg, typeof data.ok != 'undefined' && data.ok? 'message' : 'error');
                }
            }
        },
        error : function (jqXHR, textStatus, errorThrown) {
            console.log(errorThrown);
            if (fnError) {
                fnError(STR_ERROR_AJAX + textStatus);
            } else {
                topBar(STR_ERROR_AJAX + textStatus, 'error');
            }
        }
    });
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery