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
I don't think any of these answers are ideal. I know this is years late, but what you want to do is use the success/error callback options of the .ajax();
method when receiving a JSONP response.
Example of how I would structure this:
// Call
$.ajax({
// URL you want to get
url: 'http://example.com/json?callback=?',
// Set a realistic time in milliseconds
timeout: 3000,
// Put in success callback function here, this example
// shows you the data you got back from the call
success: function(data) {
console.log(data);
},
// Put in an error handling function, just an alert in this case
error: function(badData) {
alert('The call was unsuccessful');
},
type: 'POST'
});