posted 14 years ago
Hi. Is there any way to cancel an http request made by <script> tag?
Here is what I need to do.
After the page is loaded, I inject a <script> tag on a page through DOM scripting with a src = someURL.
The someURL above does not exist, so in the browser status bar, it will say "waiting for response from someURL".
After 10 seconds or so, the browser will time out the request automatically and the status bar will say "Timed out".
***
What I want to do is use javascript to force timeout of this http request before the browser auto timeout. so, if browser auto times out the request in 10 seconds, I want to force it to cancel the request in 5 seconds.
I am attempting to do this by removing the <script> tag from DOM, but even if the <script> tag is removed, the request is not cancelled (still says "waiting for response from someURL" until it auto times out.)
Is there any way to specifically kill the request being made by a <script> tag in javascript?