I am using jQuery getJSON()
function. This function getting data with no problem. But sometimes waiting, waiting waiting... And my loading bar showing loading loadi
As lethal-guitar mentioned getJSON()
function is just an shorthand for $.ajax()
. If you want to detect if a timeout has occurred rather than an actual error use the code below.
var request = $.ajax({
dataType: "json",
url: url,
data: data,
success: function( ) { },
timeout: 2000
}).fail( function( xhr, status ) {
if( status == "timeout" ) {
// do stuff in case of timeout
}
});