background preloader

Json

Facebook Twitter

What in the heck is JSONP and why would you use it? | InsideRIA. AutoSuggest jQuery Plugin. From __future__ import * » Remote JSON - JSONP. The browser security model dictates that XMLHttpRequest, frames, etc. must have the same domain in order to communicate. That's not a terrible idea, for security reasons, but it sure does make distributed (service oriented, mash-up, whatever it's called this week) web development suck. There are traditionally three solutions to solving this problem. Local proxy: Needs infrastructure (can't run a serverless client) and you get double-taxed on bandwidth and latency (remote - proxy - client). Flash: Remote host needs to deploy a crossdomain.xml file, Flash is relatively proprietary and opaque to use, requires learning a one-off moving target programming langage. Script tag: Difficult to know when the content is available, no standard methodology, can be considered a "security risk".

I'm proposing a new technology agnostic standard methodology for the script tag method for cross-domain data fetching: JSON with Padding, or simply JSONP. Let's take the del.icio.us JSON API as an example. Jabsorb. Loading Content with JSON. Introduction Thanks to the increasing use and education of efficient JavaScript techniques in today’s web applications, JSON has become the data format de jour of the enterprising young web developer.

JSON is particularly useful at loading state—passing and loading data that is unique to a particular client. The question we’ve run into around here, is what is the best way to get data off of our server and into a JSON object so it can be processed by the browser? Turns out, there’s a few ways to handle it and they each come with a few caveats. Today we’re going to examine four different approaches to creating a JSON object on page load (Ajax, innerHTML, Embedded Script Tags and Server Processed JavaScript) and discuss the pros and cons of each method. Note: Some of the example code presented below uses the JSON Parser and Prototype Framework. You may need to grab yourself a copy of each if you want to follow along. The Concept Ajax Everyone’s favorite new candy. InnerHTML Embedded Script Tags.