Skip to content
WJunction - Webmaster Forum

php Pause/Wait until ..

Status
Not open for further replies.
As i don't like to explain a lot i just give example first...

PHP:
<iframe src=http://yahoo.com/></iframe>
<?php
file_get_contents('something.txt');
 ?>

The questions is:
How can i pause file_get_contents until the iframe load ?
Alternative (worse) solution is 'executing' the iframe 5 sec before file_get_contents.

sleep() function pauses all the page :S
 

15 comments

Sleep() in a language like PHP is generally a bad idea. What you need here is client <=> server communication. Thus, you'll need to implement this in JavaScript trough AJAX. IE call a PHP script from JavaScript once the iframe is loaded. I'm sure Google can assist you with the rest of it.
 
You can do it, dont wast your time tying.

You can mix PHP with Client Side.

What you need to do is like so:

Code:
<iframe id="iframeID" src="http://google.com"></iframe>
<div id="some_content"></div>
<script>
$('#iframeID').bind('load',function(){
    //Do an ajax call
    $.get('data.php',function(data){
        $('#some_content').html(data);
    });
})
</script>

then in your data.php script echo some content.
 
Tnx litewarez ..

btw can you tell me where's the problem of this jquery :
Code:
[B]$("#img").each(function(){[/B]
$('#img').ready(function () {
$('#img').css('margin-left','auto');
$('#img').css('margin-right','auto');
$(window).load(function () {
$('#img').toggle("slow");});
}); [B]});[/B]

I am trying to toggle images on document load. The above script does it for the first match of id so i added each(the bolded one in example) so i can do it for all images using id=img ,but nothing happens :(
 
eh?? :|
Why do u confuse Javascript :| Just Remove IDs and add CLASSes. ;)
Or Instead use a selector like. $('div#parent img') :)
 
Code:
$("#img").each(function(){
    $('#img').ready(function () {
        $('#img').css('margin-left','auto');
        $('#img').css('margin-right','auto');
        $(window).load(function () {
            $('#img').toggle("slow");
        });
    });
});

the code should be:

PHP:
$(document).ready(function (){
    var Image = $('#img'); //Create an instants of the layer

    //Set the CSS
    Image.css('margin-left','auto').css('margin-right','auto');

    //toggle the image:
    Image.toggle('slow');
});
 
1112g5z.jpg


It has only border:0 in the class
 
Status
Not open for further replies.

About the author

Porsche_maniak
Active Member · Joined
Auto racing,Porsche,Web Development
283
Messages
0
Reactions
16
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom