469,294 Members | 1,662 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,294 developers. It's quick & easy.

delay execution of javascript function till php page finish executing


i got a problem that i need javascript function "ajax" to be execute after php page complete executing..

it's iframe page that uploads an image.. and the javascript function will load latest images...

i need after iframe php page uploaded the image, then javascript function be called..

anyone knows how to do this ?

thx in advance..
Sep 23 '11 #1
4 4769
8,651 Expert Mod 8TB
i got a problem that i need javascript function "ajax" to be execute after php page complete executing..
no problem. JavaScript (including AJAX) will always execute after PHP. so you might only need to delay the script execution until the website finished loading.
Sep 24 '11 #2
i have 2 php files, 1st is iframe loading, the second contain javascript ajax..

javascript function on 2nd file called and executed while iframe php page is still loading...

that's my problem : /
Sep 24 '11 #3
1,059 1GB
you can follow two method,
1. after getting the text, extract the javascript part and then create a javascript node into main document. WHen you create the node and add the javascript code to the node it will execute the code and create all required function and variable.

2. you can do it using jquery. Jquery has developed all the way to extract javascript code and execute it in proper manner. here is a simple example how you can achive
Expand|Select|Wrap|Line Numbers
  1. $.ajax(
  2. {
  3. url: "target.ext", 
  4. type: 'POST', 
  5. dataType: 'html', 
  6. data: "Parameter1=data&Parameter2=data2", 
  7. timeout: 90000, 
  8. success: 
  9. function(retData)
  10. $("#MyProcessWindow").html(retData);
  11. }
  12. }
  13. );
  14. <div id='MyProcessWindow'></div>
Sep 28 '11 #4
you can use the event onload on the iframe to run the JavaScript, e.g.
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function yourFunction()
  3. {
  4.   alert("Finished loading!");
  5. }
  6. </script>
  7. <iframe onload="yourFunction();" src="http://www.google.com"></iframe>
Oct 5 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Cristian | last post: by
8 posts views Thread by Jason Shohet | last post: by
14 posts views Thread by Rene Grothmann | last post: by
5 posts views Thread by =?Utf-8?B?TWF0Y29u?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.