Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
AJAX and PHP: Building Responsive Web Applications

You're reading from   AJAX and PHP: Building Responsive Web Applications Enhance the user experience of your PHP website using AJAX with this practical tutorial featuring detailed case studies

Arrow left icon
Product type Paperback
Published in Mar 2006
Publisher Packt
ISBN-13 9781904811824
Length 284 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (17) Chapters Close

AJAX and PHP
Credits
About the Authors
About the Reviewers
Preface
1. AJAX and the Future of Web Applications FREE CHAPTER 2. Client-Side Techniques with Smarter JavaScript 3. Server-Side Techniqueswith PHP and MySQL 4. AJAX Form Validation 5. AJAX Chat 6. AJAX Suggest and Autocomplete 7. AJAX Real-Time Charting with SVG 8. AJAX Grid 9. AJAX RSS Reader 10. AJAX Drag and Drop Preparing Your Working Environment Index

Using a Proxy Server Script


It is quite clear that unless you are building a solution where you can control the environment, such as ensuring that your users use Internet Explorer or Firefox (in which case you would need to sign your scripts or configure the browsers manually to be more permissive), accessing remote servers from your JavaScript code is not an option.

The very good news is that the workaround is simple; instead of having the JavaScript access the remote server directly you can have a PHP script on your server that will access the remote server on behalf of the client. This technique is described in the following figure:

Figure 3.12: Using a Proxy PHP Script to Access a Remote Server

To read data from a remote server with PHP we will use the file_get_contents function, whose documentation can be found at http://www.php.net/manual/en/function.file-get-contents.php.

Note

A popular (and more powerful) alternative to using file_get_contents is a library called Client URL Library (CURL...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image