I want cancel jquery $.ajax
call request with datatype json on window unload
event. I tried doing this and it is throwing error on xhr.abort();
line.
var xhr = $.ajax({
type: "POST",
url: serviceUrl,
dataType: "text json",
data: ajaxParameters,
async: true,
contentType: "application/json; charset=utf-8",
error: function(request, status, error) {
},
complete: function(e, xhr, settings) {
}
});
$(window).onunload = function(){
xhr.abort();
}