开发者

How to send some data to other pages when the main page is open?

Php is a service program, it can not do a multi threading work. It only show the page after completed all the codes. So I think, whether can send some data to other pages when the main page is open? then process divide in severa开发者_JS百科l pages, then return the data back the main page

for example: main.php, there has 3 divs.

<div id="a">aaa</div>
<div id="b">bbb</div>
<div id="c">ccc</div>  

How to open the main.php, then automatic send word aaa to a.php, word bbb to b.php, word ccc to c.php?

I prefer ajax can do it. but I search on web, can not find a tutorial which can suit me. Can any one teach me a little? Thanks.


If you are doing Ajax, are you planning on using only native Javascript, or are you open to a framework?

For example, you can do what you want with jQuery.

$(document).ready(function() {
    $("#a").load("/aaa.php");
    $("#b").load("/bbb.php");
    $("#c").load("/ccc.php");
});

What this does is wait until the DOM is ready and then uses .load to call the URL and put the results in each specified div.

To do this without a framework takes a bit more code, but of course you don't have to include the framework then (in case the framework is overkill.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜