Coder Social home page Coder Social logo

lbazz / php-infinite-scrolling Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tournasdim/php-infinite-scrolling

0.0 1.0 0.0 96 KB

Infinite scrolling , if the end of the browser-page is reached , an AJAX call request more data from a Mysql database .

php-infinite-scrolling's Introduction

<title></title>

Infinite scrolling using Ajax - JQuery - PHP

By  combining  Ajax – PHP and JQuery’s functionality  we can create amazing web-applications .
Infinite scrolling , certainly this functionality is already well known to the majority of  web-surfers . This functionality is  common nowadays on the most-visited  social-media websites ( Twitter , Facebook ) . The article of this code is located at >>>>>>> .

Requirements :

Actually there are no special requirements to set-up these code snippets . A web server that supports PHP 5+ and Mysql 5+ is adequate .
Only basic PHP and Mysql knowledge is required to set up this functionality on your development computer  . Customizing the code to your own needs isn't very difficult if you have intermediate PHP knowledge .  Of course you can visit the afforementioned link to request for help .
Note :  I 'll not respond to messages like "I have installed the scripts , but it doesn't work . Please help me " .Your request should be structured on technical details . If you have basic PHP knowledge   and exhausted your skills then you are welcome to request for help .

General overview :

  • To avoid "spaggeti code " the code is separated into three files :
    1) javascript/custom_jquery.js : this file contains all the client-side code (JQuery) . The database will be queried via an AJAX-call .
    2) jquery-masterLoader.php : This file makes the first connection to the database to return the first 30 Mysql query results .
    3) jquery-loadMoreComments.php : It  respond to AJAX requests .
  • Database credentials are stored into an separate file ( conf/my.ini) . These credentials are parsed with PHP . Although direct access to the directory of this file  is denied via .htaccess  , a good practice is to upload this file into a non publicly accessible directory of your server .
  • The JQuery library is directly downloaded from Google's AJAX API , so your server is saved from a bit of resource-cycles .
  • Requere_once is used to embed the two PHP files into the index file . Direct access is detected and prohibited . 
  • world_country.sql  : Contains the data that you can use to emulate this functionality , just uplad this file into your database via PHPMyadmin or via command line .
  • Both PHP scripts have error reporting disabled . For development , just comment the proper lines on these scripts .
  • Database connection is made via the Mysqli adapter (supported  on all  hosting  environments) .  A custom Exception  handler will thrown custom error messages  , so critical detailes will not be displayed into visitor's browser if a database error might occure .

02/09/2012 : New version released (V0.4)

  • An extra line of code is added on javascript/custom_jquery.js (line 33) . It just disables the Ajax-call when no more results are returned from  the PHP-script (most likely because the database has no more results to deliver) . This prevents Ajax from sending requests to the server even if it receives empty results .
  • A second file is added into the javascript folder (custom_jquery_debug.js) . This file has extensive "console.log" lines enabled , various messages are displayed into browser's console panel (of course  browser's developer tool should be enabled first) . If there is need for client-side debugging , import this file into index.php   instead of the defauld file (custom_jquery.js) .


License :

/**
 * Infinite scrolling 
 *
 * http://tournasdimitrios1.wordpress.com
 *
 * @copyright Tournas Dimitiros 2012
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author Tournas Dimitrios <[email protected]>
 * @version 0.3
 *
 */

php-infinite-scrolling's People

Contributors

tournasdim avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.