Ajax Hacks
Tips & Tools for Creating Responsive Web Sites

First Edition April 2006
ISBN 978-0-596-10169-5
Seiten 438
EUR29.00, SFR49.90


Weitere Informationen zu diesem Buch

Inhaltsverzeichnis | Index | Probekapitel | Kolophon | Rezensionen |
Beispiele | Online Demo |


Index

	
[ Symbols ], [ A ], [ B ], [ C ], [ D ], [ E ], [ F ], [ G ], [ H ], [ I ], [ J ], [ L ], [ M ], [ N ], [ O ], [ P ], [ Q ], [ R ], [ S ], [ T ], [ U ], [ V ], [ W ], [ X ], [ Y ], [ Z ],

Symbols[ Top ]
@ (at sign), 130
^ (caret), 157
:: (colons, doubled), 244
/* */ (comment characters, JavaScript), 109
{ } (curly braces)
      exception trapping and, 40
      JSON notation and, 30
$ (dollar sign), 157
      prototype shortcuts, 262-268, 272-275, 282-283
// (forward slashes), 109
# (hash mark), 335
<%=javascript_include_tag :defaults %> embedded tag, 298
<%...%> (Ruby script tags), 294

A[ Top ]
abort( ) method, 4
Accept-Language request headers, 223
a_complete( ) method, 327
actions, 269, 292, 315
      create_select, 301
      increment, 304
      show_env, 315
      zero_update action, 294
ActiveX program IDs for Microsoft request objects, 7
add( ) function, 344
addOptions( ) function, 251
addOptionValues( ) function, 243
addToBullets( ) function, 120
addToChecks( ) function, 113
Ajax, xvi
      back-button and, 334
      bookmarking libraries, 343
      history libraries, 343
      maintenance and performance, enhancement, 358-364
      tag debugging with Firefox, 187
      web page data, caching, 386-394
Ajax (Asynchronous JavaScript and XML), xv, 1
      included technologies, 2
      limitations, 3
      uses, xv
Ajax Massive Storage System (see AMASS)
Ajax.Autocompleter object, 325
ajaxEngine variable, 275
Ajax.InPlaceEditor object, 328
Ajax.Request object, 260-265
      go_url parameter, 264
Ajax.Updater object, 268, 273
Ajaxy, xvi
allInputs variable, 96
AMASS (Ajax Massive Storage System), 199-202
      requirements, 199
anchor hash, 335
Apache, configuration for cross-domain issues, 373-375
application ID, Yahoo Maps API, 166
application maintenance, 358-364
      bash shell script, 363
      caching issues, 361
      JavaScript file compression, 360
      JavaScript files, merging, 359-360
application.js, 298
applyLuhn( ) function, 149
associative arrays, 386
async_cmd( ) function, 391, 394
auto_com.js, 325
autocomplete( ) function, 395
auto-complete fields, 394-397
autocomplete fields
      script.aculo.us, using, 324-328
auto-completion, 324
auto_inp.js, 331
aync_cmd( ) function, 391

B[ Top ]
Backbase, 343
back-button, fixing in Ajax applications, 335-354
      iframes and bbfix.js, with, 335-342
      RSH, using, 342-354
bbfix.js, 338, 340
bb_save_state( ) function, 338
BikeBean class, 239
BikeJavaBean class, 253
blank.html, 345
bookmarklets, 197
bookmarks, fixing in Ajax applications, 342-354
browsers
      back-button and Ajax, 334
            fixing, 335-354
      compatibility detection, 5-8
            if/then testing, 6
      cross-domain request handling, 374
      filling forms without refreshes, 58-66
      history, controlling with iframes, 202-204
      locale information, finding, 223-227
      search engines, running inside, 375-380
      server data, display without refreshes, 66-71
      text handling quirks, 396

C[ Top ]
cache[cache_key].value, 392
caching issues for large applications, 361
calcTotal( ) function, 28
callback design pattern, 241
card security code (CSC), 150
cc.js, 143, 145, 153
centerCoords element, 165
checkAddress( ) function, 134-137, 140
checkboxes, 92
      dynamic generation from server data, 100-106
      immediate submission of values to the server, 92-100
      population of checkboxes from server data, 106-113
checkCSC( ) function, 153
chkZipcode( ) function, 156
client-side caching, 386-394
client-side storage for Ajax applications, 199-202
client-side validation, 126
clientsideVerify( ) function, 149, 150
code examples, xx
code obfuscation, 364
      HTML element attributes and, 365
      object property names and, 366
comment characters, JavaScript, 109
ContentHandler interface, 197
context root, 239
controller, 286, 300
controllers, 289
Cookie object, 210
cookies, 160, 204-212
      document.cookie property, 211
      MyCookie object, 210
            toString( ) method, 211
      properties, 210
count.cgi, 339
      run-time, 342
country codes, 223
createChecks( ) function, 105
createMap( ) function, 166
create_select action, 301
credit card security code validation, 150-155
      spaces, removing from form fields, 154
credit card validation, 142-150
cross-site scripting (XSS) attacks, 32
CSC (card security code), 150
CSS (Cascading Style Sheets), 2
      JavaScript code and, 52
      styled messages, generating with, 47-51

D[ Top ]
data, receiving
      as JavaScript objects (JSON), 29-37
            server-side processing, 35
      as numbers, 25-30
            calculation, 26
            display via DOM, 29
      as strings, 22
      as XML, 17-22
data validation (see validation)
db_element method, 307
dbselect.rhtml, 306
debug( ) method, 346
debugging Ajax-generated tags in Firefox, 187
declarative markup, using in place of JavaScript, 380-385
dhtmlHistory and DhtmlHistory objects, 345
DhtmlHistory class, 344
dhtmlHistory.addListener( ) method, 345
dhtmlHistory.js, 344
Direct Web Remoting (see DWR)
disform.js, 332
displayMsg( ) function, 29
displayPollResults( ) function, 98
div element, 18, 21
document.cookie property, 211
document.getElementById( ) function, 263
document.write( ) method, 123
Dojo Toolkit, 343
DOM (Document Object Model), 2
      Document objects, 18
      dynamic display of script results, 29
      elements, getting values of, 165
      getElementById( ) API method, 78
      window object, 335
DOM Inspector tool in Firefox, 187
domain literals, 130
dot property-name syntax, 71
drag-and-drop bookstore, 278-284
DWR (Direct Web Remoting), 234
      built-in Java objects, calling from JavaScript, 257-259
      callback design pattern, 241
      code, download address, 234
      custom Java objects, accessing with JavaScript, 251-256
      engine.js library, 239
      integrating into a Java web applicaton, 234-237
      Java and JavaScript mapping, 234
      populating ordered lists from Java arrays, 247-251
            function literal, 250
      selection lists
            array value, getting from the server, 239
            creating from Java maps, 242-244
            populating from a Java array, 237-242
      server setup and configuration, 235
      web page display of keys/values from Java HashMap, 244-247
            JavaScript code, 245
      WEB-INF directory, 235
dwr.jar, 234
DWRUtil.removeAllOptions( ) function, 242
dynamic information display, 397-400
dynamic script tags, 368-372
      Yahoo! Geocoding web service, 369

E[ Top ]
Effect.Appear( ) function, 323
Effect.Puff( ) method, 333
Effect.Pulsate( ) method, 333
efflib.js, 322
email, sending via XMLHttpRequest, 217-223
      EmailBean object, 223
      sendMessage( ) method, 223
email syntax, validation of, 129-138
      special characters, 130
      usernames, 138-142
            server handshake, 140
            server-side code, 141
EmailBean object, 223
email.js, 131, 139
eMsg( ) function, 137
encodeURIComponent( ) function, 65, 74
energy prices, scraping from web pages, 212-217
      EnergyHarvester class, 216
      handlePrice( ) function, 213
      JavaScript code, 213
      OilpriceCallback Java class, 215
EnergyHarvester class, 216
energy-monitoring tool, 305-309
engine.js library, 239
environment variables, 313
event handlers, 64, 102, 134
      binding to functions, 128
Extensible Markup Language (see XML)
Extensible Stylesheet Language and Transformation (see XSLT)

F[ Top ]
Firefox
      Ajax-generated tags, debugging, 187
      DOM Inspector tool, 187
      iframe domain setting, 342
      iframes and, 203
Flash and AMASS, 199, 202
form element, onsubmit event handler, 134
format_rss_data( ) function, 231
Form.Element.Observer object, 272
FormFaces, 381
FormFaces XForms engine, 381
formObj and formObjTyp variables, 63
formObj and formObj.value variables, 71
form_remote_tag( ) method, 294, 307
fragment identifier, 335
framework, 285
Fuchs, Thomas, 317
Function constructor, 34
function literal, 250, 256

G[ Top ]
GBrowserIsCompatible( ) function, 159, 161
GeoURL service, 184
GeoURL Yahoo! mash-up, 183-187
GET requests, 124, 381
getAllHeaders( ) function, 44, 49, 50, 56
getAllResponseHeaders( ) method, 4, 46
getBikeInfo( ) function, 246
get_data( ) function, 391
getDesignerInfo( ) function, 239, 250
getDirection( ) function, 173
getDocInfo( ) function, 21
getElementById( ) method, 78, 128
getElementsByTagName( ) method, 232
getInfo( ) function, 64, 68
getJsonFormat( ) method, 77
getMoreChoices( ) function, 112, 119
getResponseHeader( ) method, 5
get_rss_feed( ) function, 230
getStockPrice( ) function, 23, 26
getTimezoneOffset( ) method, 259
get_xml_file( ) function, 230
getZipCode( ) function, 193
Gnosis Utilities for Python, 376
Go Updater! button, 265
Google Maps API, 1, 158
      developer's key, 158
            requirements, 161
      DOM programming, 165
      driving directions with Yahoo! Maps, 166-175
            HTML code, 170
      Google API library, 161
      latitide and longitude measures, 165
      objects, 159
      request object, 160
      src attribute, 161
googleAjax( ) function, 161, 163
GPS devices, XML data sharing, 17
GXmlHttp, 161

H[ Top ]
hack2.js file, 10
hack3.js file, 19
hack4.js, 26
hack5.js, 32
hack6.js, 38
hack7.js file, 44
hack9.js, 23
hack10.js file, 55
hacks_2_1.js file, 61, 66
hacks_2_4.js file, 72
hacks2_5.js, 94
hacks2_7.js, 102
hacks2_8.js, 108
hacks2_9.js, 117
hacks2_11.js, 123
hacks3_6b.js, 191
hacks3_7.js, 155
hacks4_1_b.js, 171
hacks_4_4.js, 177
hacks4-10.js, 207
hacks4_12.js, 219
hacks4_13.js, 225
hacks4_1a.js, 161
hacks5_1.js, 240, 244, 249
hacks5_1.js,, 258
hacks5_3.js, 243
hacks5_5.js, 255
hacks8.js file, 50
hacks_controller.rb, 300
hacks.css, 49, 73
      drop-down box rules, 327
hacks_method.js, 127
handleJson( ) function, 34
handlePrice( ) function, 213
handleResponse( ) function, 12, 28, 39, 46, 61, 69, 75, 97, 140, 174, 194
hash keys, 386
helloworld.js, 198
helpers, 290
hidden elements, 121
hidden tag, 123
historyChange( ) method, 345
historyData, 347
HistoryStorage class, 344
historyStorage class, 348
HTML
      content, updating from the server, 265-269
            error checking, 269
            Go Updater! button, 265
      dynamic generation from strings and arrays, 400-403
      separation of code from, 127
HTMLInputElement, 97
HTTP
      PUT and GET, 381
HTTP response
      response headers, 42-47
      unordered lists, modification with, 113-121
httpd.conf, 375
httpRequest( ) function, 12, 16, 65, 112, 124, 140, 148
http_request.js, 14, 117, 143

I[ Top ]
iframes, 202
      back-button, fixing, 336
      types, 202
increment( ) method, 312
increment action, 304
index( ) method, 300
index.rhtml, 300
initialize( ) method, 352
initReq( ) function, 16, 34
inline text control validation, 126
innerInput.js, 122
.inplaceeditor-saving CSS class, 331
input elements, validation, 126
installating RoR (Ruby on Rails), 286-291
instance data, 381
instances, 135
Instant Rails, 287
Internet domains, 130
Internet Explorer
      client-side Ajax storage, 199
      iframes and, 203
Internet Explorer caching bug, 361
interval.rhtml, 310
inverted index, 376
isFirstLoad( ) method, 347
is_used tag, 140

J[ Top ]
JavaBeans, 251
java.io.FileReader class, 257
JavaScript, 2
      caching issues, solving, 361
      code, separation from HTML, 127
      commenting characters, 109
      compressing files, 360
      cross-site scripting (XSS) attacks and, 32
      CSS and, 52
      FormFaces XForms engine, 381
      large applications, maintenance, 358-364
      merging files, 359-360
      methods, 4
      script.aculo.us library (see script.aculo.us)
JavaScript obfuscators, 364
JavaScript Object Notation (see JSON)
javascript_include_tag( ) function, 298, 307
java.util.HashMap, 244
JCE (JavaScript Chaos Edition), 364
JDOM API, 277
JsBikeBean.js, 243
JsBikeJavaBean, 252
JsBikeJavaBean.toJSON( ) function, 256
JsDate and JsBikeBean objects, 236
JSON (JavaScript Object Notation), 29-37, 69
      JSONObject type, 254
      server-side processing, 35
      third-party web services request results, 368-372
JSONObject JSONArray source code, 256
JSONscriptRequest class, 369

L[ Top ]
language codes, 223
latlng variable, 165
Least Recently Used (LRU) algorithm, 387
limited_cache.js, 389
linked lists, 387
loadScript( ) function, 198
localfind( ) function, 379
LRU (Least Recently Used) algorithm, 387
Luhn algorithm, 144
      applyLuhn( ) function, 149

M[ Top ]
Mac OS X Tiger, RoR installation on, 286
makeHyperlink( ) function, 379
map objects, 163
marshalling, 254
mash-ups, 166
      Google and Yahoo! Maps APIs, 166-175
            HTML code, 170
      Yahoo! Maps and GeoURL, 183-187
Mertz, David, 376
methods, 4
Microsoft.XMLHTTP, 5
models, 286, 289
Model-View-Controller architecture (MVC), 286
monitor.rhtml, 292, 296, 299
Mozilla Firefox XMLHttpRequest object, 4
Msxml2.XMLHTTP, 5
multiple.js, 274
MVC (Model-View-Control) architecture, 286
MyCookie object, 210
mydraggable.js, 280, 281
mylib.js, 261, 262, 272
MySQL, RoR configuration for use with, 290

N[ Top ]
navigator client-side objects, 122
navigator.language property, 223

O[ Top ]
obfuscation, 334
      HTML element attributes and, 365
      object property names and, 366
      of JavaScript and Ajax code, 364-368
object literal, 35
obj.name, 97
objt variable, 35
OilpriceCallback Java class, 215
onblur event, 58, 63, 127
onblur event handler, 49
One-Click Ruby Installer, 287
onload event handler, 103
onreadystatechange, 4, 164, 386
onsubmit event handler, 134
open( ) method, 5
options.rhtml, 308
O'Reilly Mail application, 351

P[ Top ]
partial _options.rhtml, 303
partials, 303
path info, 182
PeriodicalExecuter, 272
periodically_call_remote( ) method, 310
populate( ) function, 243
populateArray( ) function, 107, 119
POST HTTP request, 8
POST requests, 124
postal code validaiton, 155-157
postal codes, fetching, 190-197
      callback object, 197
      Java servlet for, 194
      SAX (Simple API for XML) component, 194, 197
prettyPrintXml( ) method, 351
Prototype, 260
      Ajax.Request object, 260-265
            go_url parameter, 264
      download URL, 260
      Form.Element.Observer object, 272
      HTML content, updating from the server, 265-269
            error checking, 269
      monitoring changes in web page fields, 269-273
      $("msg") syntax, 273
      PeriodicalExecutor, 272
      Prototype library, 6
      Prototype objects, 272
      request headers, 269
      script.aculo.us library (see script.aculo.us)
prototype.js, 271
      library importation, 325
prototype.js library, 265
PUT, 381
put( ) method, 201

Q[ Top ]
queues, 387
Quote of the Day table, 398

R[ Top ]
Rails, 285
readyState property, 4
Really Simple History (see RSH)
remoting, 234
render( ) method, 296, 303
render :partial => "auto_ul", 327
request objects, 6
      ActiveX program IDs, 7
      custom libraries for using, 14-17
      Google Maps API, 160
      POST of data to servers, 8-14
            Googling results, 12
            setting headers, 12
      properties and methods, 4
      request object errors, handling, 37-42
            floored servers, 40
            problems, causes of, 37
            unavailable services, 41
            wrong URL, 41
      strings, data reception as, 22
      XMLHttpRequest object (see XMLHttpRequest)
request variable (JavaScript), 6
request.overrideMimeType( ) function, 21
request.status property, 41, 42
resp variable, 113
response code handling, 41, 42
response headers, 42
responseIsFailure( ) function, 265
responseText property, 4
responseXML property, 4
restore( ) function, 120
RewriteRule directive, 375
RFC 2822, 129
Rich Internet Applications, 3
Rico, 260
      drag-and-drop bookstore, 278-284
      necessary libraries, 274
      update of multiple elements with an Ajax request, 273-278
            Java servlets, 277
Rico.AjaxEngine object, 274
Rollyo, 3
RoR (Ruby on Rails), 285
      <%...%> script tags, 294
      a_complete( ) method, 327
      actions (see actions)
      application.js, 298
      calling JavaScript applications, 298
      configuration file for use with MySQL, 290
      controller, 300
      distinguishing calls by XMLHttpRequest from URL calls, 304
      dynamic viewing of XMLHttpRequest request information, 313-316
      increment action, 304
      installation, 286-291
            One-Click Ruby Installer, 287
      making periodic remote calls, 309-313
      method calls, 294
      MVC architecture, 286
      partials, 303
      remote calls, monitoring, 292-297
      render( ) method, 296, 303
      selection lists, dynamic generation using database data, 305-309
      show_env action, 315
      supported databases, 287
      template code, 292, 296, 299, 301
      templates for dynamic selection list generation, 299-304
      TimeZone object, 312
      views, 312
      web application directory structure, 289
      web applications, creating, 288
      zero_update action, 294
RSH (Really Simple History), 342
      compatible browsers, 343
RSS (Really Simple Syndication) feed reader, 227-233
      format_rss_data( ) function, 231
      get_rss_feed( ) function, 230
      get_xml_file( ) function, 230
rss.html, 229
rss_parse.js, 229
Ruby, 285
Ruby on Rails (see RoR)

S[ Top ]
Safari and iframes, 203
scraping, 212
script tags, 10
      web services requests using, 368-372
script.aculo.us, 317
      auto-complete fields, 324-328
      download web site, 318
      included script files, 318
      in-place editor fields, 328-331
      Prototype and, 317
      shaking login box on invalid logins, 320-324
      visual effects, 317-320
      web forms that disappear on submission, 332-333
scriptaculous.js
      library importation, 325
      versions, 331
search engines, running inside your browser, 375-380
select element, 74
selection lists
      creating from Java maps with DWR, 242-244
      dynamic generation from database data using RoR, 305-309
      dynamic generation from server data, 79-86
      enabling user modification option, 85-92
      immediate submission to server, 71-79
      populating from Java arrays using DWR, 237-242
            array values, getting from the server, 239
      RoR templates for dynamic generation of, 299-304
send( ) method, 5
sendData( ) function, 11
sendMessage( ) method, 223
sendSportsInfo( ) function, 96
server errors, handling, 37-42
      floored servers, 40
      problems, causes of, 37
      unavailable services, 41
      wrong URL, 41
Set-Cookie headers, 204
setHeader( ) method, 5
setProdCodes( ) function, 246
setQueryString( ) function, 10
setRequestHeader( ) function, 124
setSpan( ) function, 48, 56
setStyle( ) function, 55
setTimeout( ) method, 355
setupDates( ) function, 259
setupList( ) function, 249
setupSelect( ) function, 240
show_cache_info( ) function, 392
show_env acton, 315
showUpInfo( ) function, 268
single-page applications, xv
spaces, removing from form fields, 154
spell checkers, 66
status property, 4
statusHandler( ) function, 201
statusText property, 4
stock holding value script, 25
stock price collecting script, 22
string split( ) method, 165
stripExtraNumbers( ) function, 28
style property, 55
styled messages, 52-56
      CSS files, generating with, 47-51
stylizeDiv( ) method, 21
submit_to_remote( ) method, 315

T[ Top ]
talkdrop.js, 281
technologies used in Ajax, 2
textarea
      instant messaging hack using, 319
      server data, display without browser refreshes, 66-71
      validation, 126
      value submissions without browser refreshes, 58-66
timesUp( ) function, 356
TimeZone object, 312
toggle( ) function, 320
toggle effect, 319
toggle_visible( ) function, 398
      el.style.display attribute, 400
toGMTString( ) method, 259
toJSON( ) method, 253
toLocaleString( ) method, 259
toString( ) method, 211
try blocks, 40
try/catch/finally statement, 39

U[ Top ]
ul tag, 113, 116
UniversalBrowser privileges, 374
unmarshalling, 254
unordered lists, modification with HTTP response, 113-121
updateResults( ) function, 379
uptime.html, 336, 339
user names, validation of, 138-142
      server handshake, 140
      server-side code, 141

V[ Top ]
validation, 126
      blank fields, checking for, 126-128
      client-side validation, 126
      credit card numbers, 142-150
      credit card security codes, 150-155
            spaces, removing from form fields, 154
      email syntax, 129-138
      inline, 126
      postal codes, 155-157
      user names, 138-142
            server handshake, 140
            server-side code, 141
verify( ) function, 148
view, 286
views, 289, 312

W[ Top ]
W3C (World Wide Web Consortium), 380
Weather Forecast table, 398
weather.com, 175
      XML file of weather information, 182
web APIs, 158
web development, 158
      AMASS (see AMASS)
      bookmarklets, 198
      browser history, controlling with iframes, 202-204
      cookies, 204-212
      Google Maps API (see Google Maps API), 158
      mash-ups (see mash-ups)
      postal codes, fetching, 190-197
      weather.com XML data feed, displaying, 175-183
            pathinfo, 182
web forms, 58
      checkboxes (see checkboxes)
      data entry without browser refreshes, 58-66
      hidden tag values, submission to a server, 121-125
            logging submitted values, 125
      selection lists (see selection lists)
      server data, display without browser refreshes, 66-71
      tracking page openings, 121
      unordered lists, modification with HTTP response, 113-121
web page fields, monitoring changes in, 269-273
web page updates without refreshes, 309-313
web server uptime value, 336
web services requests with dynamic script tags, 368-372
WEBrick, 285
web.xml, 235
window object, 335
window.location hash, 335
window.onload, 128
      event handler specification, 133
window.onload event, 63
      checkboxes, changes in state, 96
window.onload event handler, 148, 192
Windows, RoR installation on, 286
window.XMLHttpRequest, 6
words file, 395
writeMap( ) function, 172

X[ Top ]
xfi.js, 377
XForms, 380-385
      FormFaces engine, 381
      XML and, 381
xf:repeat element, 385
XML (Extensible Markup Language),2, 17
      reception of data as, 17-22
XML instance data, 381
XMLHttpRequest, 2, 3-5
      asynchronous requests, 2
      browser compatibilty detection, 5-8
      browser locale information, discovering, 223-227
      calls, distinguishing from RoR URL calls, 304
      custom libraries for using, 14-17
      email, sending with, 217-223
            EmailBean object, 223
            sendMessage( ) method, 223
      energy prices, scraping from web pages, 212-217
      Mozilla Firefox implementation, 4
      setting a time limit for, 355-358
      use across domains with Apache, 373-375
      (see also request objects)
xml_http_request?( ) method, 305
XMLUtils Java class, 14
XSLT (Extensible Stylesheet Language and Transformation), 2

Y[ Top ]
Yahoo! Maps API, 166
      application ID, 166
      mash-up with GeoURL, 183-187
      mash-up with Google Maps, 166-175

Z[ Top ]
ZIP Code validation, 155-157
zoom level, 160
zoom variable, 165

	

Zurück zu Ajax Hacks


Themen

Buchreihen

Special Interest

International Sites

O'Reilly China O'Reilly France O'Reilly USA O'Reilly Japan O'Reilly Taiwan