douge3113 2016-04-07 15:33
浏览 15

在PHP中向下滚动页面时增加值

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:

  1. How can I send page_number variable to AJAX in order to increment it in there?
  2. How can I return this page_number variable in order to use in PHP code?
  3. 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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错
    • ¥15 单片机学习顺序问题!!
    • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
    • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)