background preloader

Json

Facebook Twitter

The Definitive Guide. AddSizes.js: Snazzy automatic link file-size generation | Natali. Often in the development of a site I come across the need to display the size of a document next to the link targeting it. I also like to display the type of file the link targets, for example, when linking to pdfs, mp3s or Word documents.

These indications distinguish the 'attachment' link from a normal web link, whilst also giving the user some inkling of the time they will need to wait to view the resulting content. So I was pretty excited when Simon bounded in from work and enthusiastically demonstrated json-head , a Google App Engine application he built on the train home. Every file on the web, be it a web page, a text file or whatever has HTTP headers associated with it. This is meta information about the file that is sent before the actual contents of the file itself. You can call json-head with JavaScript (JSONP). One of the first things that occurred to me was how this could be used to solve the problem of dynamically adding the file size to links. JSONLint - The JSON Validator. Jsoncss - Google Code. CSSHttpRequest - Hacks - nb.io. Cross-browser—supports IE6+, Firefox 2+, Safari 3+, iPhone 100% JavaScript—no Flash required Small—2.4KB minified Like JavaScript includes, this works because CSS is not subject to the same-origin policy that affects XMLHttpRequest.

CSSHttpRequest functions similarly to JSONP, and is limited to making GET requests. Unlike JSONP, untrusted third-party JavaScript cannot execute in the context of the calling page. A request is invoked using the CSSHttpRequest.get(url, callback) function: CSSHttpRequest.get( " function(response) { alert(response); } ); Data is encoded on the server into URI-encoded 2KB chunks and serialized into CSS rules with a modified data: URI scheme.

CSSHttpRequest * is open source under an Apache License (Version 2.0). * Or as Eric refers to it, AJACSS (slightly more electro). Examples.