Professional Documents
Culture Documents
A S Y N C H R O N O U S
J A V A S C R I P T
A N D X M L
A J A X
2
What is AJAX?
AJAX stands for Asynchronous JavaScript
and XML. AJAX is a new technique for
creating better, faster, and more
interactive web applications with the help
of XML, HTML, CSS, and Java Script.
How it works?
4
AJAX TECHNOLOGIES
AJAX cannot work independently.
It is used in combination with
other technologies to create
interactive webpages.
5
AJAX TECHNOLOGIES
JavaScript DOM CSS XMLHttpRequest
Loosely typed scripting API for accessing and Allows for a clear JavaScript object that
language. manipulating structured separation of the performs asynchronous
documents. presentation style from interaction with the
the content and may server.
be changed
programmatically by
JavaScript.
JavaScript function is Represents the structure
called when an event of XML and HTML
occurs in a page. documents.
Glue for the whole AJAX
operation.
6
AJAX EXAMPLE
Google Maps
A user can drag an entire map by using the mouse,
rather than clicking on a button.
http://maps.google.com/
7
AJAX EXAMPLE
Google Suggest
As you type, Google offers suggestions. Use the
arrow keys to navigate the results.
http://www.google.com/webhp?complete=1&hl=en
8
AJAX EXAMPLE
Gmail
Gmail is a webmail built on the idea that emails
can be more intuitive, efficient, and useful.
http://gmail.com/
9
XMLHttpRequest Object
The XMLHttpRequest object is the key
to AJAX. XMLHttpRequest (XHR) is an API that
can be used by JavaScript, JScript, VBScript,
and other web browser scripting languages to
transfer and manipulate XML data to and from a
webserver using HTTP, establishing an
independent connection channel between a
webpage's Client-Side and Server-Side.
12
variable = new
13
14
15
Status Text
1xx: Information
18
2xx: Successful
19
3xx: Redirection
20
GET or POST
GET or POST
GET is FASTER THAN POST. However, always use
POST requests when:
A cached file is not an option (update a file
or database on the server).
Sending a large amount of data to the server
(POST has no size limitations).
Sending user input (which can contain unknown
characters), POST is more robust and secure
than GET.
25
26
27
28
29
Asynchronous
To send the request asynchronously, the async parameter
of the open method has to be set to true.
Methods Description
XML FILE
BLACKMAI cd_catalog.x
L ml
XML FILE
BLACKMAI
L
BLACKMAI
L
AJAX- PHP
• PHP is a programming language that
allows web developers to create dynamic
content that interacts with databases.
• Ajax uses XHTML for content, CSS for
presentation, along with Document Object
Model and JavaScript for dynamic content
display.
AJAX- PHP
Using
Array
1.Function
5.
2.
7.
3.
4. Var
6.
8. (this.readyState
xmlhttp.send();
xmlhttp =<input
xmlhttp.open("GET",
xmlhttp.onreadystatechange == "gethint.php?q="
new XMLHttpRequest(); 4 && this.status
= function()
type="text" +
{
crs,
==
} The200)
true);
Document.getElementById(“txtHint”).innerH
onkeyup="showHint(this.value)">
send()
readyState
open(method,
Function()
-
new 4:
function request
keyup()- Function
finished
async)
XMLHttpRequest(); and response
document.getElementById(elementID)
url,
functionName(parameters)
expressions
method triggers will execute
the keyup { is ready
event, automatically if the expression
or attaches a function is followed
to run when a keyupby (), "self-invoking".
event occurs.
Sends a request
code to to
be the server
executed (used for GET)
TML=“”;
status
Specifies
}
Creates
.innterHtml
-
onreadystatechange
the type
200:a new
of - A XMLHttpRequest
request
OK -
function to
way
method: the type of request: GET or POST
be
to object
called
modify when
the the readyState
content of an property
HTML changes
element
5.
1. $len=strlen($q);
2.
4.
3. q=$_REQUEST[“q”];
$q = strtolower($q);
foreach($a (stristr($q,
as $name) {
substr($name,
…The }
$_REQUEST
strlen() is afunction
stristr(string,search)
foreach function
strtolower()
loop HTTP
Theonly
returns
works 0,
Request
stristr()
the
converts
on $len))
avariables
function
length of
string
arrays, andato and
usedused
searches
string.
islowercase.
to to
forloop
the
collect data
eachafter
first occurrence
through ofsubmitting
a string
key/value anan
pairinside
in HTML
array.form.
another Notice:
string.
xmlhttp.open("GET", "gethint.php?q="
substr(string,start,length) The substr()+function
crs, true);returns a
part of a string.
AJAX- PHP
Using Database
4.Retrieving
6.
5.
3.Connecting
2.
1. Link Css
Create data
Connecting
Creating new from
New
& form
Database
Databasefor
Jquery the
Comment database
to the
new comments
and Create and
the
Performing
Database
Script Ajax
A S Y N C H R O N O U S
J A V A S C R I P T
A N D X M L
THANK YOU
A J A X