PHP and AJAX

Download Report

Transcript PHP and AJAX

PHP and AJAX
Servers and Clients
For many years we tried to move as much
as possible to the server.
Weak clients, poor bandwidth, browser compatibility..
Created a certain way of interacting with a
website.
Request – Response model.
Clients and Servers
Client machines have become much more
powerful.
You’re not using much of your duel core processor
rendering a webpage
Bandwidth has increased dramatically
9.5 million broadband users in the UK (2006, BBC)
“Broadband now makes up 57.4% of all net
connections compared to 42.6% for dial-up. In the
last year dial-up connections had shrunk by 28.7%”
(2005, BBC)
14,520,988 Q2 2007
(http://www.thinkbroadband.com/news/3280-number-of-uk-broadband-users-nearing-saturation-point.html)
Clients and Servers
Browsers now run JavaScript in a more
predictable manner.
So the technology is ready for AJAX but
what is it?
What isn't AJAX
A Language
A Technology
A Plug-in
Proprietary
All that hard
The answer to all of our dreams
What is AJAX?
Asynchronous JavaScript and XML
What is asynchronous?
Uses JavaScript and XML to create
seamless interaction on a website.
Lots of CSS sites look ‘real purty’ but still
have the response/request model of
interaction.
Using Obvious forms for their interaction.
AJAX
“It uses the JavaScript XMLHttpRequest
function to create a tunnel from the client's
browser to the server and transmit
information back and forth without having
to refresh the page.”
Ajax has become synonymous with any
rich web application or Web 2.0 / 3.0
application.
http://coldfusion.sys-con.com/read/138966.htm
PHP and Ajax
 XMLHttpRequest Object
 “XMLHttpRequest (XHR) is an API that can be used by JavaScript, and other web
browser scripting languages to transfer XML and other text data to and from a web
server using HTTP, by establishing an independent communication channel between
a web page's Client-Side and Server-Side.” - Wiki
• Created in IE:
var AlsAjaxObject = new ActiveXObject("Microsoft.XMLHTTP");
• In other browsers:
var AlsAjaxObject = new XMLHttpRequest();
Demos
Image Editor
Text Stuff
Google Suggests
Google Maps
Some tutorials
 http://www.w3schools.com/php/php_ajax_datab
ase.asp
 http://www.ibm.com/developerworks/xml/library/o
s-php-rad1/
 http://www.phpbuilder.com/columns/kassemi200
50606.php3
 http://www.phpbuilder.com/columns/kassemi200
50606.php3
 http://www.johnwiseman.ca/blogging/tutorials/cre
ating-a-mysql-connection-with-phpajax/
Links – Further Reading
http://dhtmlnirvana.com/ajax/ajax_tutorial/
http://ajaxpatterns.org/wiki/index.php?title=
Whats_Ajax
http://www.maxkiesler.com/index.php/webl
og/comments/round_up_of_50_ajax_toolki
ts_and_frameworks/
http://www.ajaxwith.com/PHP
http://www.fiftyfoureleven.com/resources/p
rogramming/xmlhttprequest/examples