you’re on your way 4
95
ajax requests
Break Neck’s PHP script
Let’s ask Frank over in the server-side group to write us a PHP script to
look up customer addresses. Then you can send the customer’s phone
number to this script, and get the customer’s address as a response.
Team Chat: Talking to the Server
Team Chat: Talking to the Server
Hey, Frank, you’re good with PHP, right?
Team Chat: Getting Some PHP Help
Team Chat: Getting Some PHP Help
Yeah, sure. What do you need?
I’ve got a customer’s phone number from an order
form.You think you could write a script that gives me
that customer’s address based on their number?
In the book’s examples, look in the chapter02/breakneck directory,
and nd the lookupCustomer.php script. This is a PHP script that will
run without a database server; keep this le on your computer, or
FTP it to your web site—you’ll be using it in just a sec.
...then I can use JavaScript to update my HTML on the y.
Jim
Frank
Jim
No, I’m making an asynchronous request, so I won’t
need anything but the raw data...
Jim
Sure, just send over the phone number as a request
parameter. You want me to return their information
as part of a new HTML page?
Frank