Gehtland - Pragmatic Ajax - Web 2.0 Primer (Raleigh, 2006).pdf

(3930 KB) Pobierz
19072713 UNPDF
19072713.017.png
Pragmatic Ajax
A Web 2.0 Primer
Justin Gehtland
Ben Galbraith
Dion Almaer
The Pragmatic Bookshelf
Raleigh, North Carolina Dallas, Texas
 
Many of the designations used by manufacturers and sellers to distinguish their products
are claimed as trademarks. Where those designations appear in this book, and The
Pragmatic Programmers, LLC was aware of a trademark claim, the designations have
been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The
Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g
device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher
assumes no responsibility for errors or omissions, or for damages that may result from
the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team
create better software and have more fun. For more information, as well as the latest
Pragmatic titles, please visit us at
Copyright © 2006 The Pragmatic Programmers LLC.
All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmit-
ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior consent of the publisher.
Printed in the United States of America.
ISBN 0-9766940-8-5
Printed on acid-free paper with 85% recycled, 30% post-consumer content.
First printing, March 2006
Version: 2006-4-27
19072713.018.png 19072713.019.png 19072713.001.png 19072713.002.png 19072713.003.png 19072713.004.png 19072713.005.png 19072713.006.png 19072713.007.png 19072713.008.png 19072713.009.png 19072713.010.png 19072713.011.png 19072713.012.png 19072713.013.png 19072713.014.png 19072713.015.png
Contents
vii
1
1.1 A Tale in Three Acts . . . . . . . . . . . . . . . . . . . . .
2
1.2 Google Maps: The Missing Spark . . . . . . . . . . . . .
4
1.3 What Is Ajax? . . . . . . . . . . . . . . . . . . . . . . . . .
5
1.4 Whither Now? . . . . . . . . . . . . . . . . . . . . . . . . .
8
9
2.1 Rocket Scientists? . . . . . . . . . . . . . . . . . . . . . .
10
2.2 Your Own Google Maps . . . . . . . . . . . . . . . . . . .
11
2.3 Creating Ajaxian Maps . . . . . . . . . . . . . . . . . . .
16
2.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . .
47
48
3.1 Ajaxifying a Web Application . . . . . . . . . . . . . . . .
48
3.2 Ajax to the Rescue . . . . . . . . . . . . . . . . . . . . . .
48
3.3 The Grubby Details . . . . . . . . . . . . . . . . . . . . .
56
3.4 Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . .
59
60
4.1 A Review of Client-Side JavaScript . . . . . . . . . . . . .
61
4.2 Manipulating the Web Page . . . . . . . . . . . . . . . . .
67
4.3 Retrieving Data . . . . . . . . . . . . . . . . . . . . . . . .
73
4.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . .
76
77
77
5.2 Remoting with the Dojo Toolkit . . . . . . . . . . . . . . .
82
90
5.4 Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . .
92
 
CONTENTS
v
6.1 Ajax and JavaScript for the UI . . . . . . . . . . . . . . . 93
6.2 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . 121
7.1 Some Standard Usages . . . . . . . . . . . . . . . . . . . 122
7.2 It Isn’t All Just Wine and Roses... . . . . . . . . . . . . . 137
7.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . 146
8.1 View Source . . . . . . . . . . . . . . . . . . . . . . . . . . 147
8.2 DOM Inspectors . . . . . . . . . . . . . . . . . . . . . . . 148
8.3 JavaScript Debugging . . . . . . . . . . . . . . . . . . . . 160
8.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . 169
9.1 What Is Degradable Ajax? . . . . . . . . . . . . . . . . . . 170
9.3 Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . . 183
10.1 JSON-RPC . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
12.1 The PHP Frameworks . . . . . . . . . . . . . . . . . . . . 195
12.2 Working with Sajax . . . . . . . . . . . . . . . . . . . . . 196
12.3 XOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
12.4 Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . . 209
13.1 Ruby on Rails . . . . . . . . . . . . . . . . . . . . . . . . . 210
13.2 Ajax Integration . . . . . . . . . . . . . . . . . . . . . . . . 214
13.3 The Future of Ajax in Rails . . . . . . . . . . . . . . . . . 227
14.1 DWR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
14.2 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . 245
19072713.016.png
Zgłoś jeśli naruszono regulamin