开发者

How insert PHP output into html div replacing temp graphic

开发者 https://www.devze.com 2023-03-15 04:50 出处:网络
I need to display an html page and within the page is a divinto which I want to echo the o开发者_如何学Pythonutput of a PHP page.

I need to display an html page and within the page is a div into which I want to echo the o开发者_如何学Pythonutput of a PHP page.

While the PHP page is being fetched and prepared I want to display a "Loading" msg and a temporary gif.

I have the html code working and I have the PHP code working/echo'ing.

How do I echo the contents of the PHP page to replace the original contents of the Div.? (I guess - with an include:file and an innerhtml statement, but how/where?)

A Javascript solution would be fine.

Thanks


Add a div to your page with the image in it, then using jQuery:

 $('#myDiv').load('mypage.php');


You're essentially looking to make an asynchoronous call to your php script once the page is loading, so JavaScript is your friend.

When the page loads, include the loading message and the temporary gif, then do an ajax call to your php script and insert the response into the relevant div.

As @Sjoerd points out - jQuery will do this for you nicely.


take a look into ajax:

The Low-down

Using ajax with jQuery

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号