Prev | Current Page 276 | Next

Rich Cannings, Himanshu Dwivedi, Zane Lackey, and Alex Stamos

"Hacking Exposed Web 2.0: Web 2.0 Security Secrets and Solutions"

Here??™s the client??™s request:
GET http://www.example.com/zipcode_lookup.jsp?city=seattle
And here??™s the server response:
for( var i=0; i < keys.length; i++ ) {
var e = document.getElementsByName( keys[i][0] );
for ( j=0;j < e.length; j++ ) {
e[j].value = keys[i][1];}}
JavaScript Arrays
Similar to the server passing back full JavaScript, the server may also pass back data in
the form of JavaScript arrays. In this case, the arrays full of data are passed back to the
client, which then eval()s them. Existing JavaScript on the client then notices that the
data in the arrays has changed, and refreshes the DOM with the new data. Following is
an example of a client calling a zip code lookup method on the server, with the server
returning JavaScript arrays which will be executed in an eval() on the client. Here is
the client request:
GET http://www.example.com/zipcode_lookup.jsp?city=seattle
And here is the server response:
var zipcodes = ["98101", "98102"];
JSON
Often billed as the ???lightweight alternative??? to using XML, JavaScript Object Notation
(JSON) is used by a large number of AJAX applications. Despite an odd look, JSON is
actually raw JavaScript that is equivalent to JavaScript arrays.


Pages:
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
gadżety reklamowe info Druk wielkoformatowy Blog przeprowadzki wrocław