I'm using...
$.getJSON(url + "&callback=?", function (b) {
.......
});
for a long-polling request. Sometimes it is necessary that I stop the current request being made. Is this possible?
I'm using...
$.getJSON(url + "&callback=?", function (b) {
.......
});
for a long-polling request. Sometimes it is necessary that I stop the current request being made. Is this possible?
I think this works, but have never tried it for myself...
var theRequest = $.getJSON(url + "&callback=?", function (b) {
.......
});
theRequest.abort(); // aborts the xmlhttprequest made
$.getJSON()
should return the XMLHTTPRequest object, upon which you call the abort()
method.
Not sure if you're aborting because it's taking too long, but if so you can change your $.getJSON call to $.ajax and set a timeout:
$.ajax({url: url, dataType:'json', data: "param1=" + params,timeout: 7000, success:resultsHandler })