Skip to content

serverSync with callback using synchronous XMLHttpRequest fails  #65

@samgavinio

Description

@samgavinio

The suggested serverSync implementation with synchronous XHR (taken from http://keith-wood.name/countdownRef.html)

$(selector).countdown({ 
    until:liftoffTime, serverSync: serverTime
}); 

function serverTime() { 
    var time = null; 
    $.ajax({url: 'http://myserver.com/serverTime.php', 
        async: false, dataType: 'text', 
        success: function(text) { 
            time = new Date(text); 
        }, error: function(http, message, exc) { 
            time = new Date(); 
    }}); 
    return time; 
}

would soon begin failing across all browsers due to the deprecation of synchronous XMLHttpRequests due to its negative effect on user experience. Please see: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-extensions/WH1wOAxJQiM

At the moment there is no other way to use serverSync except for providing a callback that returns the server time using a synchronous XMLHttpRequest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions