Jump to content

I have a PHP variable resetting when I'm trying to combine it with jquery to load new content.


HeartLess

Recommended Posts


<?php
$tag = isset($_GET['tag']) ? $_GET['tag'] : null;
$load = isset($_GET['load']) ? $_GET['load'] : time();
$load = Product::lastTime($load, $tag);
?>

<script type="text/javascript">

$(document).ready(function(){

//lastAddedLiveFunc();
$(window).scroll(function(){

var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height();
var scrolltrigger = 0.95;

if ((wintop/(docheight-winheight)) > scrolltrigger) {

alert("<?php echo $load;?> <?php echo $tag;?>");
//console.log('scroll bottom');
lastAddedLiveFunc();
}
});
});

function lastAddedLiveFunc()
{
$.get("pages/load.php", {load: "<?php echo $load ;?>", tag: "<?php echo $tag;?>"}, function(data){
if (data != "") {
//console.log('add data..');
$(".threecols").append(data);
<?php
$load = Product::lastTime($load, $tag);
?>
}
});

alert("<?php echo $load;?> <?php echo $tag;?>");
};
</script>
My Product:lastTime function works properly as indicated by the second alert() line. The alert box gives me a new number. However, the next time I run lastAddedLiveFunc() when it's called by scrolling my window, the value of $load goes back to it's original value (as if the page had refreshed). Does anyone have any idea how to fix this? There's more code obviously but it's all html and has nothing to do with the php.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.