取消活动的ajax请求

I have read that its not possible to cancel an active ajax request, however i have seen many places where its actually being done.

Most webpages will show a "stuck loading" link after a few seconds of loading.

I'm trying to figure out if it is somehow possible, to kill the request, and restart it again, when the loading have been going on for "too long".

I hope you have a few hints for me.

Thank you

The XMLHttpRequest object has an abort method which can be used to cancel a request which has been sent:

xmlHttpReqObj.abort();

I don't think this works in Internet Explorer below version 7, so if you need to support those then you may be out of luck.