Skip to Content
JAVASCRIPT網頁應用程式設計
book

JAVASCRIPT網頁應用程式設計

by Alex MacCaw
January 2013
Intermediate to advanced
332 pages
5h 23m
Chinese
GoTop Information, Inc.
Content preview from JAVASCRIPT網頁應用程式設計
54
|
第三章
然後再把伺服器回傳的資料傳進
Model.populate()
函式裡:
jQuery.getJSON("/assets", function(result){
Asset.populate(result);
});
如此一來,伺服器回傳的所有資料,都會被寫進 ORM 裡面了。
將資料儲存在用戶端
在過去,要把資料存在用戶端是一件非常麻煩的工作。以前唯一可行的做法,就是把資
料存在 cookie 裡,或是利用像 Adobe Flash 這樣的外掛程式。但 cookie 所提供的 API
在相當老舊,它無法用來儲存大量資料,而且它會在每次送出請求時,都把所有的資料
全部傳到伺服器去,增加許多不必要的網路傳輸資料量。至於 Flash,嗯…我想我們最
好還是儘可能避免使用外掛程式會比較好。
不過還好,HTML5 的規格已經有提供在用戶端儲存資料的功能,而且各大瀏覽器也都
有實作此功能。這個功能和 cookie 不同,它不單會將資料儲存在用戶端,而且這些資料
永遠不會傳送到伺服器端。你可以利用這個功能儲存大量的資料—資料量的上限會隨著
瀏覽器的不同而有差異(瀏覽器版本也會有影響),不過基本上每個網域至少都能儲存
5MB 的資料量:
IE >= 8
Firefox >= 3.5
Safari >= 4
Chrome >= 4
Opera >= 10.6
HTML5 的儲存區機制,定義在 HTML5 的網頁儲存區(web storage)規格中(
http://
www.w3.or
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

Ethan Brown, 武舎 広幸, 武舎 るみ
PHP编程:第4版

PHP编程:第4版

Kevin Tatroe, Peter MacIntyre
Strange Code

Strange Code

Ronald T. Kneusel
Perfecting Your Thinking Skills

Perfecting Your Thinking Skills

MIT Sloan Management Review

Publisher Resources

ISBN: 9789862766811