Book Image

jQuery 2.0 Development Cookbook

By : Leon Revill
Book Image

jQuery 2.0 Development Cookbook

By: Leon Revill

Overview of this book

Table of Contents (17 chapters)
jQuery 2.0 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Caching JSON and AJAX requests


One way by which a web developer can increase the speed of his/her web application is by limiting the number of requests made to the web server. It is very important to ensure that you are making data calls only when you need to. We can use caching to ensure that requests are made only when a new set of data is required.

Getting ready

Ensure that your web server is up and running and you have permission to add files to the server's web root directory.

How to do it…

Learn how to speed up your JavaScript applications using simple caching methods by performing the following instructions:

  1. Create a PHP file named request-6.php in the web root of your web server. Use the following PHP code to create and output a list of names as JSON data:

    <?php
      //Create an array of people
      $people = array(
        1 => array(
          "firstname" => "Luke",
          "lastname" => "Skywalker"
        ),
        2 => array(
          "firstname" => "Darth",
          "lastname" => "Vader...