PHP Classes

Simple PHP AJAX Load Page Without Refresh: Load pages faster dynamically using AJAX requests

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2023-11-20 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 216 All time: 8,292 This week: 59Up
Version License PHP version Categories
simple-php-dynamic-p 1.0.0The PHP License5HTML, PHP 5, AJAX, Global
Description 

Author

This package can load pages faster dynamically using AJAX requests.

It provides JavaScript code to load pages dynamically, sending AJAX requests to a PHP server-side script and replacing the current page contents with script response.

The JavaScript code can keep track of the page's history, so when the user uses the browser's back and forward buttons, it can go back to the previous or next page.

Innovation Award
PHP Programming Innovation award nominee
November 2023
Number 4
The speed of load of the pages is one factor that determines a site's quality.

AJAX requests can be used to make page loads faster by only retrieving the parts of a page that change when a user clicks on a link or submits a form that makes another page load.

This package provides a JavaScript library to make pages load dynamically using AJAX requests while preserving the browser history of pages, so the user can use the browser back and forward buttons to navigate in the browser page history.

Manuel Lemos
Picture of Okanlawon Anuoluwapo
  Performance   Level  
Name: Okanlawon Anuoluwapo <contact>
Classes: 4 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 364928 in Nigeria Nigeria
Week rank: 83 Up4 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 3x

Example

<?php
$call_type
= isset($_GET['callType']) ? $_GET['callType'] : "";

// Request to API for dynamic page

$home = array(
       
'status' =>'success',
       
'title' => 'Home Page',
       
'description' => 'Home description',
       
'url' => '',
       
'content' => '<span>This is <strong>Home</strong> content coming from ajax url</span>'
   
);

    if (
$call_type == "about") :
       
       
$response = array(
           
'status' => 'success',
           
'title' => 'About Page',
           
'description' => 'About description',
           
'url' => $call_type,
           
'content' => '<span>This is <strong>About</strong> content coming from ajax url</span>'
       
);
   
    elseif (
$call_type == "contact") :
       
       
$response = array(
           
'status' =>'success',
           
'title' => 'Contact Page',
           
'description' => 'Contact description',
           
'url' => $call_type,
           
'content' => '<span>This is <strong>Contact</strong> content coming from ajax url</span>'
       
);

    elseif (
$call_type == "home") :
       
$response = $home;
    elseif (
$call_type == "invoice") :

       
$response = array(
           
'status' => 'success',
           
'title' => 'Invoice receipt Page',
           
'description' => 'Invoice receipt description',
           
'url' => $call_type,
           
'content' => file_get_contents('pages/invoice.html'),
        );

    else :
       
$response = $home;
    endif;

echo
json_encode($response);


Details

simple-php-dynamic-page

Dynamic page without page refresh with php and ajax request


  Files folder image Files  
File Role Description
Files folder imagepages (1 file)
Accessible without login Plain text file ajax.php Example Auxiliary script
Accessible without login Plain text file functions.php Aux. Auxiliary script
Accessible without login Plain text file index.php Example Auxiliary script
Accessible without login Plain text file main.js Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file style.css Data Auxiliary data

  Files folder image Files  /  pages  
File Role Description
  Accessible without login HTML file invoice.html Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:216
This week:0
All time:8,292
This week:59Up