Jquery Ajax error handling to ignore aborted

Error comes from when the web page refresh too much fast than it can load.

For example, a web page load a huge data, even with ajax pagination, and users refresh multiple times of this page

 

Solution which resolved this problem :

var unloaded = false;
$(window).bind('beforeunload', function(){
    unloaded = true;
});

$(document).ajaxError(function(event, request, settings) {
    if (unloaded || request.statusText == "abort") {
        return;
    }
    ...
}

Ref.
http://stackoverflow.com/questions/4807572/jquery-ajax-error-handling-to-ignore-aborted

Advertisements

[XMLHttpRequest] Cross-domain Ajax REST request + No ‘Access-Control-Allow-Origin’ header is present on the requested resource

Context :

In summary, this article is to record the solution for an “No ‘Access-Control-Allow-Origin’ header is present on the requested ressource” error.

My local domain is : localhost, in which based my local application

My request domain is : http://www.example.com, which is write in PHP, and will return a simple object in JSON
Such as : {"return":"OK"}

Continue reading