27.10.2015 Views

AJAX and PHP

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

interrupting the user from his or her current activity. You'll find an example of <strong>AJAX</strong> form<br />

validation in Chapter 4.<br />

The examples where <strong>AJAX</strong> can make a difference are endless. To get a better feeling <strong>and</strong><br />

underst<strong>and</strong>ing of what <strong>AJAX</strong> can do for you, have a look at these live <strong>and</strong> popular examples:<br />

Chapter 1<br />

• Google Suggest helps you with your Google searches. The functionality is pretty<br />

spectacular; check it out at http://www.google.com/webhp?complete=1. Similar<br />

functionality is offered by Yahoo! Instant Search, accessible at<br />

http://instant.search.yahoo.com/. (You'll learn how to build similar<br />

functionality in Chapter 6.)<br />

• GMail (http://www.gmail.com). GMail is very popular by now <strong>and</strong> doesn't need<br />

any introduction. Other web-based email services such as Yahoo! Mail <strong>and</strong> Hotmail<br />

have followed the trend <strong>and</strong> offer <strong>AJAX</strong>-based functionality.<br />

• Google Maps (http://maps.google.com), Yahoo Maps (http://maps.yahoo.com),<br />

<strong>and</strong> Windows Live Local (http://local.live.com).<br />

• Other services, such as http://www.writely.com <strong>and</strong> http://www.basecamphq.com.<br />

You'll see even more examples over the course of this book.<br />

Just as with any other technology, <strong>AJAX</strong> can be overused, or used the wrong way. Just<br />

having <strong>AJAX</strong> on your website doesn't guarantee your website will be better. It depends<br />

on you to make good use of the technology.<br />

So <strong>AJAX</strong> is about creating more versatile <strong>and</strong> interactive web applications by enabling web pages<br />

to make asynchronous calls to the server transparently while the user is working. <strong>AJAX</strong> is a tool<br />

that web developers can use to create smarter web applications that behave better than traditional<br />

web applications when interacting with humans.<br />

The technologies <strong>AJAX</strong> is made of are already implemented in all modern web browsers, such as<br />

Mozilla Firefox, Internet Explorer, or Opera, so the client doesn't need to install any extra modules<br />

to run an <strong>AJAX</strong> website. <strong>AJAX</strong> is made of the following:<br />

• JavaScript is the essential ingredient of <strong>AJAX</strong>, allowing you to build the client-side<br />

functionality. In your JavaScript functions you'll make heavy use of the Document<br />

Object Model (DOM) to manipulate parts of the HTML page.<br />

• The XMLHttpRequest object enables JavaScript to access the server<br />

asynchronously, so that the user can continue working, while functionality is<br />

performed in the background. Accessing the server simply means making a simple<br />

HTTP request for a file or script located on the server. HTTP requests are easy to<br />

make <strong>and</strong> don't cause any firewall-related problems.<br />

• A server-side technology is required to h<strong>and</strong>le the requests that come from the<br />

JavaScript client. In this book we'll use <strong>PHP</strong> to perform the server-side part of the job.<br />

15<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!