Thank you for looking at my question, as I appreciate your time.
Okay, so I'm trying to use jQuery's get function to call my php script which ultimately returns a variable which is a built template of the main content of my page minus my static header/footer, for which I would like to replace the "old" page content without the page reloading. Can anyone point me in the right direction as to where I'm going wrong here? My code is as follows...
jQuery:
function getData(time, type) {
$.ajax({
type: "GET",
url: "getData.php",
data: "time=" + time + "&type=" + type,
success: function(data){
$('#pageContent').fadeOut("slow");
$('#pageContent').html(data);
$('#pageContent').fadeIn("slow");
}
});
return false;
}
getData.php(paraphrased):
....
$time = empty($_GET['time']) ? '' : $_GET['time'];
$type = empty($_GET['type']) ? '' : $_GET['type'];
echo getData($time, $type);
function getData($time, $type)
......
.....
$tmpl = new Template();
$tmpl->time= $time;
$tmpl->type = $type;
$builtpage = $tmpl->build('index.tmpl');
return $builtpage;
.....
......
jQuery function call:
<a href="#" onclick="getData("<?php print $tmpl->time; ?>", "Orange")">Orange</a>
<a href="#" onclick="getData("<?php print $tmpl->time; ?>", "Apple")">Apple</a>
<a href="#" onclick="getData("<?php print $tmpl->time; ?>", "Banana")">Banana</a>
When I click any link, the ajax seems to run fine, and the page does refuse to reload, but the content still remains unchanged... Anyone happen to know what's up?