Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
25
rated 0 times [  32] [ 7]  / answers: 1 / hits: 25453  / 15 Years ago, sat, november 14, 2009, 12:00:00

I wish to do something iframe-like with my div i've got going here.



Basically, i've gotten as far as making links change the content of the div like so:



<a href=#self onClick=document.getElementById('maincontent').innerHTML = '<?php include 'file.php'; ?>';>Open file</a>


This works pretty well, sadly though, if i make another link inside that to change the content back to the first file, the server gets stuck in an infinite loop and crashes.



I really am just trying to find some way to dynamically change content, and to fetch that content from a file using php. If my way of approaching this is completely ludicrious, i do appreciate suggestions.


More From » php

 Answers
0

I think the best and easiest way is to use jQuery:



<script type=text/javascript>
$('#addContent').click(function(){
$(#maincontent).load(file.php);
return false;
});
</script>

<a href=# id=addContent>Open File</a>
<div id=maincontent></div>


This script will load content of file.php into selected div using ajax call.


[#98313] Tuesday, November 10, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
erick

Total Points: 588
Total Questions: 92
Total Answers: 100

Location: Bangladesh
Member since Sat, Jan 23, 2021
3 Years ago
;