ajax, json, and client-side templates

15
AJAX, JSON, AND CLIENT SIDE TEMPLATES

Upload: rtigger

Post on 05-Dec-2014

2.423 views

Category:

Technology


0 download

DESCRIPTION

Why AJAX, JSON, and Client-Side Templates are the new Web.

TRANSCRIPT

Page 1: AJAX, JSON, and Client-Side Templates

AJAX, JSON, AND CLIENT SIDE TEMPLATES

Page 2: AJAX, JSON, and Client-Side Templates

AJAX• Asynchronous Javascript And XML

• HTML and CSS• Document Object Model• XML and XSLT• XMLHttpRequest• JavaScript

Page 3: AJAX, JSON, and Client-Side Templates

Web 1.0

Example: www.ebay.ca

Page 5: AJAX, JSON, and Client-Side Templates

JSON• JavaScript Object Notation

• Lightweight data-interchange format• Easy for humans to read and write• Easy for machines to parse and generate

Page 6: AJAX, JSON, and Client-Side Templates

JSON• Built on two structures:

• Name value pairs (aka object)

• Ordered list of values (aka array)

• Combination thereof

• Virtually all languages support these structures

{ Name: “Value”, Name2: 2, Name3: true }

[ “value”, 2, true ]

[ { Name: “Object 1”, Numbers: [1,2,3] }, { Name: “Object 2”, Numbers: [4,5,6] } ]

Page 7: AJAX, JSON, and Client-Side Templates

JSON vs XML

Page 8: AJAX, JSON, and Client-Side Templates

JSON vs XML

Page 9: AJAX, JSON, and Client-Side Templates

Old HTML WayPage, ViewPerPage, ID Search,Name Search, SKU Search, Price From,Price To, Position From, Position To

Page 10: AJAX, JSON, and Client-Side Templates

AJAX Partial Rendering Way

ID Search,Name Search, SKU Search, Price From,Price To, Position From, Position To

Page 11: AJAX, JSON, and Client-Side Templates

Client Side Templates

[ {Product}, {Product}, {Product} ]

GET /Products?Page=2

Page 12: AJAX, JSON, and Client-Side Templates

Client Side Templates• Pros

• Separation of data and layout• Faster page load

• No wait time on server, simply serving up a HTML document• Less content

• Less network traffic• Smaller requests and responses

• Server doesn’t have to worry about generating HTML• Able to maintain page state in JavaScript if needed• Lots of opportunities to cache

Page 13: AJAX, JSON, and Client-Side Templates

Client Side Templates• Cons

• Initial page load is essentially empty• Bad idea for pages you want indexed by a search engine

• JavaScript heavy• No canned controls• Async can be tough on groups of objects or sequential operations

Page 14: AJAX, JSON, and Client-Side Templates

Example!

http://localhost:8080/Playlists

Page 15: AJAX, JSON, and Client-Side Templates

Questions!?