Trigger ajax event on iframe load
|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Trigger ajax event on iframe loadI am trying to trigger an ajax event when my iframe is loaded. I kind of understand the concept, but I am slightly confused. If I do get the even triggered after my iframe has loaded, what do I do to get the fake ajax event to use a function? $('#testFrame').load(function () { $.event.trigger('success'); }); Basically I want to run a function when a link is clicked to load content into an iframe, and then run another function when the iframe content has loaded. Thanks! |
|
|
Re: Trigger ajax event on iframe loadHey there, I hope I understand this right. Say you have a link with class mylink. Once clicked you want to load mypage.php into a frame with id testFrame. After everything has loaded you would like to trigger an alert with the message Hello. This would look something like the code below: $('a.mylink').click( function () { $('#testFrame').load("mypage.php", function () { alert ("Hello"); }); }); I hope this helps :) Maybe you could look at the ajax function as well as it has callbacks for success and error responses from the server. (http:// docs.jquery.com/Ajax/jQuery.ajax#options) k On Nov 3, 10:43 am, Nic Hubbard <nnhubb...@...> wrote: > I am trying to trigger an ajax event when my iframe is loaded. I kind > of understand the concept, but I am slightly confused. If I do get > the even triggered after my iframe has loaded, what do I do to get the > fake ajax event to use a function? > > $('#testFrame').load(function () { > $.event.trigger('success'); > > }); > > Basically I want to run a function when a link is clicked to load > content into an iframe, and then run another function when the iframe > content has loaded. > > Thanks! |
|
|
Re: Trigger ajax event on iframe loadHi Kru, I am wanting to use the load event (http://docs.jquery.com/Events/ load) to know when the iframe has been loaded, not load content into a div. #testFrame is the ID of my iframe. What I would like to do is use ajax events triggers to fake some ajax events, e.g. $.event.trigger('success'); . But I am not sure I understand what to do once I add $.event.trigger('success'); . On Nov 2, 2:34 pm, Kru <curdi...@...> wrote: > Hey there, > > I hope I understand this right. Say you have a link with class mylink. > Once clicked you want to load mypage.php into a frame with id > testFrame. > After everything has loaded you would like to trigger an alert with > the message Hello. > > This would look something like the code below: > > $('a.mylink').click( function () { > $('#testFrame').load("mypage.php", function () { > alert ("Hello"); > }); > > }); > > I hope this helps :) > Maybe you could look at the ajax function as well as it has callbacks > for success and error responses from the server. (http:// > docs.jquery.com/Ajax/jQuery.ajax#options) > > k > > On Nov 3, 10:43 am, Nic Hubbard <nnhubb...@...> wrote: > > > I am trying to trigger an ajax event when my iframe is loaded. I kind > > of understand the concept, but I am slightly confused. If I do get > > the even triggered after my iframe has loaded, what do I do to get the > > fake ajax event to use a function? > > > $('#testFrame').load(function () { > > $.event.trigger('success'); > > > }); > > > Basically I want to run a function when a link is clicked to load > > content into an iframe, and then run another function when the iframe > > content has loaded. > > > Thanks! |
|
|
Re: Trigger ajax event on iframe loadBasically, I would like to have the functionality that the jQuery Form plugin uses for uploading files. When you click submit it fires and ajax event, even though it is not using ajax, then, when the iframe is loaded, the ajax success is trigged. Thanks. On Nov 2, 2:53 pm, Nic Hubbard <nnhubb...@...> wrote: > Hi Kru, > > I am wanting to use the load event (http://docs.jquery.com/Events/ > load) to know when the iframe has been loaded, not load content into a > div. #testFrame is the ID of my iframe. > > What I would like to do is use ajax events triggers to fake some ajax > events, e.g. $.event.trigger('success'); . But I am not sure I > understand what to do once I add $.event.trigger('success'); . > > On Nov 2, 2:34 pm, Kru <curdi...@...> wrote: > > > Hey there, > > > I hope I understand this right. Say you have a link with class mylink. > > Once clicked you want to load mypage.php into a frame with id > > testFrame. > > After everything has loaded you would like to trigger an alert with > > the message Hello. > > > This would look something like the code below: > > > $('a.mylink').click( function () { > > $('#testFrame').load("mypage.php", function () { > > alert ("Hello"); > > }); > > > }); > > > I hope this helps :) > > Maybe you could look at the ajax function as well as it has callbacks > > for success and error responses from the server. (http:// > > docs.jquery.com/Ajax/jQuery.ajax#options) > > > k > > > On Nov 3, 10:43 am, Nic Hubbard <nnhubb...@...> wrote: > > > > I am trying to trigger an ajax event when my iframe is loaded. I kind > > > of understand the concept, but I am slightly confused. If I do get > > > the even triggered after my iframe has loaded, what do I do to get the > > > fake ajax event to use a function? > > > > $('#testFrame').load(function () { > > > $.event.trigger('success'); > > > > }); > > > > Basically I want to run a function when a link is clicked to load > > > content into an iframe, and then run another function when the iframe > > > content has loaded. > > > > Thanks! |
| Free embeddable forum powered by Nabble | Forum Help |