Example to show ajax abort
HTML
<script src="https://code.jquery.com/jquery-2.2.0.min.js" integrity="sha256-ihAoc6M/JPfrIiIeayPE9xjin4UWjsx2mjW/rtmxLM4=" crossorigin="anonymous""></script>
<button>
Click me
</button>
JavaScript
$('button').on('click', function() {
var _ajax = $.ajax({
type: 'POST',
url: 'https://tripplanner.riderta.com/API/api/Trip/GetRealtimeBusesforRouteID?routeid=10',
crossDomain: true,
dataType: 'json'
}).fail((responseData) => {
if (responseData.responseCode) {
console.error(responseData.responseCode);
}
});
_ajax.abort();
});