Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying PHP Ajax Cookbook
  • Table Of Contents Toc
PHP Ajax Cookbook

PHP Ajax Cookbook

By : Milan Sedliak
4 (5)
close
close
PHP Ajax Cookbook

PHP Ajax Cookbook

4 (5)
By: Milan Sedliak

Overview of this book

This book contains a collection of recipes with step-by-step directions to build SEO-friendly websites using standard Ajax tools. Each recipe contains behind-the-scene explanations to PHP Ajax questions. This book is an ideal resource for people who like to add Ajax features to websites and who prefer standards and best practices for building SEO-friendly websites. As the book covers advanced topics, readers need to be aware of basic PHP, JavaScript and XML features.
Table of Contents (16 chapters)
close
close
PHP Ajax Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1
Index

Sequencing Ajax Requests


As the name suggests, Ajax is asynchronous, so the sequence of code might not be followed, as most of the logical activities are done when the HTTP request is completed.

How to do it ...

Let's try to understand the Ajax request with an example:

$(document).ready(function()
{  
    $.ajax({
    type: "POST",
    url: "test.php",
    data:'json',
    data: "bar=foo",
    success: function(msg){
    console.log('first log');
    }
  });
   
  console.log('second log')
   
});

Once executed, the preceding code is seen as follows in the Firebug console:

How it works...

Although the $.ajax function is called first, due to the asynchronous nature of the code, the second log is printed first (as this line of code follows directly after the $.ajax function). Then, success: function gets executed when the HTTP request is completed and, after that, first log gets printed to console.

Sequencing Ajax requests is a technique that is widely used in real-time applications. In the following...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
PHP Ajax Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon