I have read the other similar questions, but not found the answer, so here it is:
<?php     
function load($page) {     
    echo "page: ".$page;
}
echo "
<script type='text/javascript'>
  var page = 0;
  window.addEventListener(...., function(){
    var x = .....
    ......
    if(x = ....)
    {
      page = page + 1;
      var runQuery = '<?php load(page); ?>'
    }
  })
</script>  
";    
?>
The problem is that <?php load(page); ?> is not executed. If I write load(page); outside the echo, it works. Can anyone help me ?
 
     
    