Client-Side Programming JavaScript & Ajax - University of California ...
嚜澧SE 135
Client-Side Programming
JavaScript & Ajax
From pure server to client/server
computation
? So far we have seen pure server-side
programming
Next
? Enrich user experience, interactivity with clientside computations (JavaScript)
每 For example, validate that the user typed a number in
a textbox
? Combine the best of both worlds with Ajax
technologies
每 Assignment focus: live views
2
Architecturally speaking:
Pure server-side programming
Pure server-side architecture
Browser
Current
New page
Page
Form submission
leads to request
Server responds
with new, typically
HTML page
Server
3
1
Architecturally speaking:
Client-side programming w Javascript
Browser
Current Page
Javascript
code
User events may lead to activation of
Javascript code, evaluated by the browser.
They lead either to alerts, prompts, etc or
to modification of part (
) of the page
Server
4
Architecturally speaking:
Ajax programming (@10 miles high)
Browser
Current Page
Javascript
request-producing code
Javascript responsehandling code updates
Server responds with data that are
enough for the page update (
)
Event leads to
Javascript activation,
leading to
http request
Server
5
Preview: From basics to higher-level
programming
1. First examples will demonstrate the essentials:
每 Directly accessing and manipulating the DOM object
representation of the data shown on the browser
每 Packing & unpacking response data via XML
每 Not part of assignment 每 just broad knowledge
2. Making Javascript/DOM programming easier
with utilities
每 Transferring data via JSON
每 Jquery
3. (much later) High level frameworks where you
can altogether avoid Javascript
每
每
每
FORWARD
Ruby-on-Rails partials
GWT
6
2
JavaScript
? Programming language embedded in HTML
每 Directly or indirectly
? Evaluated by the browser, interpreted
? Triggered on page load and on certain
programmer-defined events
? While OO, it allows weak typing and many
oddities
每 Great opportunities for making a coding mess
7
JavaScript Example 1
9
3
Basics
? Incorporate code in element
? Code in part evaluates on page load
? Code in part are typically functions
waiting for events triggered by the user*s
activity on the browser
? Typical control structures
每 Statements, conditionals, loops, functions...
? Typical expressions
? JavaScript can access and modify the HTML
document and its parts (HTML elements)
currently displayed
10
Specific available objects
? Predefined JavaScript objects:
每
每
每
每
每
Window: Represents a browser window
Navigator: Contains browser info
Screen: Contains client screen info
History: Visited URLs within a browser window (tricky)
Location: Info about the current URL
? The displayed HTML*s DOM tree
每
每
每
每
每
Document: Top of navigation
Area: Areas you may have defined inside maps
Form
Option
#
11
JavaScript Example 3
16 and 16)
document.write("Good Evening");
else
document.write("Hello");
12
4
Interaction Basics: Popup Boxes
? Alerts
每 Make sure the user saw something
? Confirmations
每 Click either "OK" or "Cancel" to proceed
? Prompts
13
JavaScript Example 4
#
response =
confirm("If you proceed we*ll charge your card");
document.write(response);
14
JavaScript Example 5
#
response =
prompt(※The page will be whatever you type here",
"default");
document.write(response);
15
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- ece 304 running a net list file in ps
- lesson 7 if statement and comparison operators pace university new york
- 3 consider the following fragment of javascript give the output that
- chapter 15 javascript 4 objects and arrays university of cape town
- practice more javascript a level it 9626 mrsaem
- chapter 16 javascript 3 functions university of cape town
- statistical software for data science stata
- littlefs stensat
- cs106a stanford handout 53 fall 2003 04 nick parlante files
- 17csl77 web technology lab with mini project atria
Related searches
- university of california essay prompts
- university of california supplemental essays
- university of california free tuition
- university of california campuses
- university of california online certificates
- address university of california irvine
- university of california at irvine ca
- university of california irvine related people
- university of california irvine staff
- university of california irvine employment
- university of california irvine address
- university of california irvine online