0

When dynamically inserting an iframe into a webpage, the JQuery load event allows me to trigger a callback function when this iframe is loaded (see also this stackoverflow article).

The problem I am struggling with, is that I want to do something when the src request is sent to the server but before the response is received from that server. In other words, I am looking for an event like "request fired". The JQuery load event doesn't seem to help here.

I have been playing with several values for the JQuery setTimeout method, but that doesn't look like a very robust solution to me.

Community
  • 1
  • 1

2 Answers2

2

I am not sure why you would need that event. When you call the JQuery method, you know the request is being made so you would call your method there.

epascarello
  • 204,599
  • 20
  • 195
  • 236
  • I agree. @Matthijs, can you explain why you are looking for a little more clearly. It sounds like the request would be sent immediately when you insert the iframe. – Prestaul Jan 15 '09 at 04:42
1

The iframe loads the "src" url as soon as its added to the document.body.

var iframe = document.createElement("iframe");
iframe.src = "http://somesite.com";

document.body.appendChild(iframe);
// request fired, your code would go here
Luca Matteis
  • 29,161
  • 19
  • 114
  • 169