Loading dynamic external content into the Div of another on click
Posted
by Robin I Knight
on Stack Overflow
See other posts from Stack Overflow
or by Robin I Knight
Published on 2010-04-21T15:25:09Z
Indexed on
2010/04/21
15:53 UTC
Read the original article
Hit count: 230
Trying to load an external php file into another onClick. Iframes will not work as the size of the content changes with collapsible panels. That leaves AJAX. I was given a piece of code
HTML
<a href="#" id="getData">Get data</a>
<div id="myContainer"></div>
JS
$('#getData').click(function(){
$.get('data.php', { section: 'mySection' }, function(data){
$('#myContainer').html(data);
});
});
PHP:
<?php
if($_GET['section'] === 'mySection') echo '<span style="font-weigth:bold;">Hello World</span>';
?>
I have tested it here http://www.divethegap.com/scuba-diving-programmes-dive-the-gap/programme-pages/dahab-divemaster/divemaster-trainingA.php and get the most unexpected results. It certainly loads the right amount of items as it says in the lower bar on safari but I see three small calendars and that is it. Can anyone see where I have made a mistake?
© Stack Overflow or respective owner