Aborting AJAX

Aborting AJAX

cmorbitzercmorbitzer Posts: 1Questions: 1Answers: 0

Hi there!

I was wondering if there was a simple way to abort a current AJAX call in a DataTable, or retrieve the jqXHR object generally. I dug into the code and was able to make this work:

resultsTable = $("#resultsTable").DataTable({ ...

$("#cancel-ajax").click(function(){
$.fn.DataTable.settings[0].jqXHR.abort();
});

But I'm curious if there's a better way I missed, or if there's a way that doesn't rely on me knowing this is the only or first DataTable in my script.

This discussion has been closed.