- 浏览: 54711 次
- 性别:
- 来自: 广州
最新评论
-
Joson_Coney:
11.
while( (*strDest++ = *strSr ...
c++笔试题汇总 -
Joson_Coney:
③ 1.
int func(x)
{
int countx = ...
c++笔试题汇总 -
Joson_Coney:
链表反向1:
#include <cstdlib&g ...
c++笔试题汇总
( From : http://bob.pythonmac.org/archives/2005/12/05/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. 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. The way JSONP works is simple, but requires a little bit of server-side cooperation. Basically, the idea is that you let the client decide on a small chunk of arbitrary text to prepend to the JSON document, and you wrap it in parentheses to create a valid JavaScript document (and possibly a valid function call). The client decides on the arbitrary prepended text by using a query argument named jsonp with the text to prepend. Simple! With an empty jsonp argument, the result document is simply JSON wrapped in parentheses. Let's take the del.icio.us JSON API as an example. This API has a "script tag" variant that looks like this: http://del.icio.us/feeds/json/bob/mochikit+interpreter: In terms of JSONP, a document semantically identical to this would be available at the following URL: http://del.icio.us/feeds/json/bob/mochikit+interpreter?jsonp=if(typeof(Delicious)=='undefined')Delicious={};Delicious.posts= That's not very interesting on its own, but let's say I wanted to be notified when the document is available. I could come up with a little system for tracking them: The fetched URL from this hypothetical experiment would look something like this: http://del.icio.us/feeds/json/bob/mochikit+interpreter?jsonp=delicious_callbacks[12345] See, because we're wrapping with parentheses, a JSONP request can translate into a function call or a plain old JSON literal. All the server needs to do differently is prepend a little bit of text to the beginning and wrap the JSON in parentheses! Now, of course, you'd have libraries like MochiKit, Dojo, etc. abstracting JSONP so that you don't have to write the ugly DOM script tag insertion yourself, etc. Of course, this just solves the standardization problem. Your page is still toast if the remote host decides to inject malicious code instead of JSON data. However, if implemented, it'd save a lot of developers some time and allow for generic abstractions, tutorials, and documentation to be built.Remote JSON - JSONP
December 05, 2005 at 08:21 PM | categories: AJAX, javascript, MochiKit | 15 Comments
if(typeof(Delicious) == 'undefined') Delicious = {}; Delicious.posts = [{ "u": "http://mochikit.com/examples/interpreter/index.html", "d": "Interpreter - JavaScript Interactive Interpreter", "t": [ "mochikit","webdev","tool","tools", "javascript","interactive","interpreter","repl" ] }]
var delicious_callbacks = {}; function getDelicious(callback, url) { var uid = (new Date()).getTime(); delicious_callbacks[uid] = function () { delete delicious_callbacks[uid]; callback(); }; url += "?jsonp=" + encodeURIComponent("delicious_callbacks[" + uid + "]"); // add the script tag to the document, cross fingers }; getDelicious(doSomething, "http://del.icio.us/feeds/json/bob/mochikit+interpreter");
delicious_callbacks[12345]([{ "u": "http://mochikit.com/examples/interpreter/index.html", "d": "Interpreter - JavaScript Interactive Interpreter", "t": [ "mochikit","webdev","tool","tools", "javascript","interactive","interpreter","repl" ] }])
发表评论
-
【转】Compiling with cython and mingw produces gcc: error: unrecognized command lin
2012-05-03 10:46 1031(From: http://stackoverflow.com ... -
Java Annotation入门
2012-04-17 15:01 0(转自:http://www.blogjava.net/eri ... -
【转】DNS协议报文(RFC1035)
2012-01-27 06:46 1296(转自:http://hi.baidu. ... -
【转】Protocol Header Images
2012-01-27 06:45 604http://www.troyjessup.com/heade ... -
【转】DNS协议及应用
2012-01-27 06:44 871(转自http://jwx.zgz.cn/cl/7 ... -
DNS 伺服器
2012-01-26 06:03 501DNS 伺服器http://linux.vbird.org/l ... -
HTTP Request
2012-01-26 06:02 722HTTP Request Published ... -
HTTP multipart/form-data 上传方式说明
2012-01-26 06:01 826( From: http://home.meegoq.c ... -
Java:对象的强、软、弱和虚引用
2012-01-09 15:00 530原创作品,允许转载,转载时请务必以超链接形式标明文 ... -
Struts2源码分析--请求处理
2011-12-01 10:03 607(转自:http://www.blogjava.ne ... -
java web学习笔记
2011-11-21 09:50 546Tomcat Configuration 资 ... -
c++笔试题汇总
2011-10-23 16:11 633(转自http://blog.csdn.net/dongfen ... -
c++中使用引用传递来提高效率
2011-10-23 14:37 864(转自:http://www.diybl.com/course ... -
[转] HTTP multipart/form-data 上传方式说明
2011-10-15 06:08 1263( From: http://home.meegoq.co ... -
Multipart uploading spec
2011-10-15 06:07 638Upload File: abc.txtContent:abc ... -
【转】Webcam Manipulation with Javascript
2011-10-15 06:04 757( From:http://blog.trumpton.org ... -
GTK+ 中文显示解决方案
2011-10-15 06:01 603(转自:http://www.wangchao.net.cn/ ... -
Table单元格td的position:relative的兼容性
2011-10-11 12:35 1874( From: http://www.itref.cn/a/ ... -
a lib: jXHR (JSON-P XHR)
2011-10-11 12:18 652http://mulletxhr.com/ -
GTK+主循环(main loop)的工作原理
2011-10-11 11:59 1069GTK+主循环(main loop)的工作原理 转 ...
相关推荐
json-viewer, 它是用于打印JSON和JSONP的Chrome 扩展 JSON查看器 你的眼睛所见过的最漂亮和可以定制的json/。 它是用于打印JSON和JSONP的Chrome 扩展。注释:这里扩展可能会与其他JSON萤火虫/格式化程序发生碰撞,你...
$jsonp ( '/some-jsonp-url' , { myCustomUrlParam : 'veryNice'} ) 直接使用功能: import { jsonp } from 'vue-jsonp'jsonp ( '/some-jsonp-url' , { myCustomUrlParam : 'veryNice'} )发送数据并设置查询和函数...
前端项目-fetch-jsonp,Fetch JSONP like a boss using Fetch API
json-formatter, 使 json/jsonp易于阅读 JSON格式化程序当你在浏览器选项卡中访问 in'直接'时,很好的打印JSON和tmodel的Chrome 扩展。特性JSONP支持快速,即使在长页面上有效的JSON页面- URL不重要语法高亮显示带有...
jquery-jsonp插件
适用于axios的jsonp适配器支持承诺,支持取消,与xhr相同安装npm install axios-jsonp用法let axios = require('axios');let jsonpAdapter = require('axios-jsonp');axios({ url: '/jsonp', adapter: jsonpAdapter,...
您所见过的最美丽,最可定制的JSON / JSONP荧光笔。 这是一个Chrome扩展程序,用于打印JSON和JSONP。 笔记: 此扩展名可能与其他JSON荧光笔/格式化程序一起崩溃,您可能需要禁用它们 要突出显示本地文件和隐身...
终于找到了一个好用的jquery-jsonp插件,可以完美的支持jsonp请求。可以完美的支持jsonp请求。
Ajax-parse-jsonp.zip,获取jsonp响应的有效负载。,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于创建动态网页,其中网页的小部分在不重新加载网页的情况下...
Ajax-cors-jsonp-sample.zip,客户端和服务器端(Java)用于跨源资源共享(CORS)的示例。,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于创建动态网页,其中...
第25周-第06章节-Python3.5-JSONP跨域请求jQuery方式.avi
JSON to JSONP- Bypass Same-Origin Policy
12 React 获取数据 axios插件 fetch-jsonp插件的使用(26分15秒)
网络故障或格式错误的JSON 响应时的错误恢复, 精确控制回调命名及其在 URL 中的传输方式, 多个具有相同回调名称的请求同时运行, 两种缓存机制(基于浏览器和基于页面), 可以像任何其他 AJAX 请求一样手动...
使用jsonp跨域获取json数据。Ajax获取JAVA服务器json数据。
axios-add-jsonp 向axios添加jsonp方法安装$ npm install axios-add-jsonp --save例子统一所有请求import request from 'axios-add-jsonp'request . jsonp ( '/api/123' , { bar : foo , foo : bar } ) . then ( res...
soundcloud-resolve-jsonp 使用带有 corslite 的 SoundCloud API 解析端点和用于 Safari 的 JSONP 回退 入门 npm install soundcloud-resolve-jsonp var resolve = require ( 'soundcloud-resolve-jsonp' ) ; var ...
7、为了便于客户端使用数据,逐渐形成了一种非正式传输协议,人们把它称作JSONP,该协议的一个要点就是允许用户传递一个callback参数给服务端,然后服务端返回数据时会将这个callback参数作为函数名来包裹住JSON数据...
jsonp实现sso跨域登录。这个代码实际上是自己写的一个demo。部署后,先在a项目login.jsp登录,然后再进入a和b项目的index.jsp就能看到已经登录。
该资源为ASP.NET网站开发技术中使用Ajax进行跨域请求时利用JSONP方案解决浏览器同源策略限制的源码,比较简单,仅供参考