27.10.2015 Views

AJAX and PHP

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Server-Side Techniques with <strong>PHP</strong> <strong>and</strong> MySQL<br />

The web application will look like Figure 3.15:<br />

Figure 3.15: Making Repetitive Asynchronous Requests<br />

This repetitive task must start somewhere. In our application, everything starts with process().<br />

There, we decide what kind of server request to make; we can either ask for a new r<strong>and</strong>om<br />

number, or we can check for the buffer level of the r<strong>and</strong>om number generator server. We check for<br />

the buffer level every 10 requests, <strong>and</strong> by default we don't ask for new r<strong>and</strong>om numbers unless the<br />

buffer is higher than 50% . The process is described in the flowchart given opposite:<br />

92<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!