PHP Classes

File: main.js

Recommend this page to a friend!
  Classes of Okanlawon Anuoluwapo   Simple PHP AJAX Load Page Without Refresh   main.js   Download  
File: main.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Simple PHP AJAX Load Page Without Refresh
Load pages faster dynamically using AJAX requests
Author: By
Last change:
Date: 7 months ago
Size: 1,002 bytes
 

Contents

Class file image Download
const loadPage = (page_url) => { $.getJSON( page_url + "ajax.php", { callType: "" }, function (data, textStatus, xhr) { // console.log(data); $(document).attr("title", data.title); $(document) .find("meta[name=description]") .attr("content", data.description); window.history.pushState("", "", page_url); $(document).find(".main").html(data.content); } ); $(document).on("click", ".btn_load_screen", function (e) { e.preventDefault(); const callType = $(this).attr("callType"); $.getJSON( page_url + "ajax.php", { callType: callType }, function (data, textStatus, xhr) { // console.log(data); $(document).attr("title", data.title); $(document) .find("meta[name=description]") .attr("content", data.description); $(document).find(".main").html(data.content); window.history.pushState("", "", page_url + data.url); } ); }); };