Really Basic AJAX With Jquery
Really Basic AJAX With Jquery
with JQuery
By Bill Welense
IM 332 at DePaul University
Winter 2008
What is AJAX?
Asynchronous JavaScript and XML
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 Extensible Mark-up Language
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