HeartLess Posted October 27, 2013 Share Posted October 27, 2013 (edited) <?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. Edited October 27, 2013 by HeartLess Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 27, 2013 Share Posted October 27, 2013 <?php $load = Product::lastTime($load, $tag); ?>That's PHP which is parsed on the page request, then when in javascript it will be static as is your alert call content... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.