• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javascript Question (DOM)

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are better off using a serverside proxy and use the XMLHttpRequest Object.

You might be able to pull it off using an iframe and adding the script tag into there.

Eric
 
Something about .... going for a swim. With this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic