Really Basic AJAX with JQuery

sinceresatisfyingΛογισμικό & κατασκευή λογ/κού

2 Ιουλ 2012 (πριν από 4 χρόνια και 9 μήνες)

287 εμφανίσεις

Really Basic AJAX
with JQuery
By Bill Welense
IM 332 at DePaul University
Winter 2008
What is AJAX?
A
synchronous
J
avaScript
a
nd
X
ML
Common uses
Form validation
Date and time
Drag and drop
What is 'Asynchronous'?
Content on the user's screen can be modified without
refreshing the screen
Data from a program (a
web service
) can be displayed on
the user's screen without navigating away from the current
page
What is JavaScript?
JavaScript is a scripting language built in to web browsers
Can be effectively used to manipulate HTML and CSS
Similar to Java only in that it's programming syntax is the
same
Does not require a run-time environment such as Flash or
J2RE
What is XML?
XML stands for E
x
tensible
M
ark-up
L
anguage
XML's purpose is to provide a simple way to transfer
information from one application to another
It is similar to HTML, but the tags are dependent on your
definitions
The W3C does have specifications for how XML should be
formatted, used, etc.
How to use AJAX
Browser support can be finicky
ActiveX control is used for Internet Explorer
DOM (Document Object Model) is used to W3C-compliant
browsers (Firefox, Safari, Opera, etc.)
To start from scratch, AJAX requires quite a bit of
programming just to get started
Best to use a free library, such as JQurey of Prototype
These libraries can easily handle remote data provided
throughXML web services
What is a Web Service?
Very basic definition: A program that generates an XML file
containing requested information
Supplies raw data, rather than data formatted for display
on a screen
Data can be manipulated by another application (such as
an AJAX-based web application)
Data can be re-used for many different applications
("mash-ups")
What is JQuery?
A comprehensive AJAX library
Lets you write less code
Has a very simple API (Application Programming Interface)
Uses a special JavaScript "namespace" to map itself to the
$ character, which is not used in JavaScript
Rather than causing an error, the JQuery library is
invoked
Code is then processed through JQuery
Can easily combine standard JavaScript with JQuery
Can easily locate and modify elements in an HTML
document by the 'id' or 'class' values
Resources
AJAX
http://www.w3schools.com/ajax/default.asp
JQuery
http://jquery.com/
AJAX Example
http://www.billwelense.com/depaul/ajaxdemo/currentTime.html
Web Service Example
http://www.billwelense.com/depaul/ajaxdemo/currentDateTime.php