Hi All,

I have one index.php like below

.....
......
<head>
<script type="text/javascript">
ajax function to call page1, page2 etc...
</script>

</head>

<body>

<div id="leftcolumn">
<a href="javascript:ajaxpage('page1.php', 'rightcolumn');">Page1</a>
<a href="javascript:ajaxpage('page2.php', 'rightcolumn');">Page2</a>
<a href="javascript:ajaxpage('page3.php', 'rightcolumn');">Page3</a>

</div>

<div id="rightcolumn"><h3>Choose a page to load.</h3></div>
<div style="clear: left; margin-bottom: 1em"></div>

</body>

</html>

Now if page1 is calling some other page say page4 as

page1.php

......
......
<a href="javascript:ajaxpage('page4.php', 'rightcolumn');">page4</a>

.....

Here I am unable to understand how to do this as page1 does not have any div with name rightcolumn and also it does not have the ajaxpage script.

Please let me know how to do this....I hope I am clear.

On index.php, when you call ajaxpage('page1.php', 'rightcolumn');

then your rightcolumn will have html - the html from page1.php:

<div id="rightcolumn">
<a href="javascript:ajaxpage('page4.php', 'rightcolumn');">page4</a>
</div>

When you click on page4, it should load it into the rightdiv of index.php because that link now exists within index.php.

On another note, page1.php should NOT send any element with id="rightcolumn" because index.php already has an element with that id. An id MUST be unique throughout the document even if you are populating elements via ajax.

thanks a lot. It is so easy to use ajax. This is working perfectly...thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.