Reputation: 2845
i Wonder how i can create an invisible iframe and get its final content in to main page too not only inside the iframe? (Note. My invisible iframe url is in same domain and is written in php and i can modify it for my requirement).
<iframe id ='myframe' src='http://www.mydomain.com/process.php'></iframe>
My goal is to show user some sort of loading animation while invisible iframe finishes its process (usually it takes 10 seconds to finish ) and then show the final output in main page and removes the loading animation.
My invisible iframe redirects to another php url(also in same domain) and outputs some data but i want to show this data inside my main page also not only inside invisible iframe. Could you guys tell me how this can done ?
Upvotes: 2
Views: 397
Reputation: 4204
Use ajax
to share state b/w them or you can perform animations in one window and when it finishes, you can open a new window using window.open();
I have never tried ajax in this way, but:
<frameset cols="25%,*,25%">
<frame src="frame_a.php">
<frame src="frame_b.php">
</frameset>
When animation on frame_a.php
finishes, a JavaScript method can use ajax to communicate with frame_b.php
That method inside the <script></script>
on frame_a.php
will send post or get parameters to frame_b.php
. Don't worry about loading... it is fast enough if you do not have a lot of resources (css/js files). Moreover, if you do not want the user to wait you can set some default animation on frame_b.php
.
This is what the method should contain:
function share_state_with_frame_b(state) {
$.ajax({
type: "POST",
url: "frame_b.php",
data: { d1: "v1" , d2: "v2" }
}).done(function( msg ) {
// close frame_a.php
});
}
Upvotes: 1
Reputation: 56
This what you looking for? Otherwise I could only think to use ajax
for this.
Upvotes: 1