I am making web site for my project. Since there are lots of image in my website, I want to display them page by page. Here is the little code snippet from my code:
PHP:
$page_number = 1;
$url_polls = 'http://sitename.herokuapp.com/api/v1/polls/extended/page/' . $page_number;
$string = file_get_contents($url_polls);
$result = json_decode($string, true);
When you increase the page_number, new images will come to the page. In order to increase page_number variable, web page have to be scrolled down. Here is the code snippet for jquery function:
jQuery:
<script type="text/javascript">
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
}
});
</script>
This script recognizes when reaching at the end of the page by scrolling down. I want to ask couple of questions:
- How can I send page_number variable to AJAX in order to increment it in there?
- How can I return this page_number variable in order to use in PHP code?
- Is there any easy way to increment page_number just by using jQuery code?
Sorry for long post, I am newbie in web-development. Thanks in advance.