0

I have a html page which has multiple html links . Once you click the link the corresponding page will be shown in the right side frame. When I click one of the link , the web-server takes much time to respond and it is inconsistent .

My requirement is , i have to start a timer when i click on a page if the page is not served within some predefined timeout then i need to cancel the http request which is submitted on this server. How to achieve this.

This is not ajax request . just plain html href request onclick of a link.

Thanks.

Rob
  • 14,746
  • 28
  • 47
  • 65
JavaUser
  • 25,542
  • 46
  • 113
  • 139
  • What do you want to do when you cancel the request? What should actually happen on the client? One way for instance would be to remove the right hand frame, or direct it off to another page etc. The last request fired at the frame will "win". – James Thorpe Apr 08 '16 at 14:03
  • Yes You are right ..the last request wins.But the requirement is , if the first request itself fails then why the other request are being made.I need to have a spinner and avoid the subsequent request if the first one fails. – JavaUser Apr 08 '16 at 14:06
  • What would happen if the subsequent requests are made before the timeout of the first request? How would you know the first one would have failed? – apokryfos Apr 08 '16 at 14:11
  • i want to catch the failure – JavaUser Apr 08 '16 at 14:13
  • 1
    Similar question: [Catch error if iframe src fails to load](http://stackoverflow.com/questions/15273042/catch-error-if-iframe-src-fails-to-load-error-refused-to-display-http-ww). Solution uses onload event with timer. – Yogi Apr 08 '16 at 14:41

1 Answers1

0

Since you are not using AJAX and just making a standard href link request, you can't really cancel the request, but if you have set up a timer in your page, the best you'd be able to do is make a different request when the time is up.

You said that this wasn't AJAX, but you didn't say that you can't use AJAX. This would be very easy to accomplish with AJAX. Any reason not to use it?

Scott Marcus
  • 64,069
  • 6
  • 49
  • 71