- 浏览: 57224 次
- 性别:
- 来自: 广州
最新评论
-
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 1063(From: http://stackoverflow.com ... -
Java Annotation入门
2012-04-17 15:01 0(转自:http://www.blogjava.net/eri ... -
【转】DNS协议报文(RFC1035)
2012-01-27 06:46 1333(转自:http://hi.baidu. ... -
【转】Protocol Header Images
2012-01-27 06:45 658http://www.troyjessup.com/heade ... -
【转】DNS协议及应用
2012-01-27 06:44 942(转自http://jwx.zgz.cn/cl/7 ... -
DNS 伺服器
2012-01-26 06:03 530DNS 伺服器http://linux.vbird.org/l ... -
HTTP Request
2012-01-26 06:02 762HTTP Request Published ... -
HTTP multipart/form-data 上传方式说明
2012-01-26 06:01 865( From: http://home.meegoq.c ... -
Java:对象的强、软、弱和虚引用
2012-01-09 15:00 555原创作品,允许转载,转载时请务必以超链接形式标明文 ... -
Struts2源码分析--请求处理
2011-12-01 10:03 648(转自:http://www.blogjava.ne ... -
java web学习笔记
2011-11-21 09:50 590Tomcat Configuration 资 ... -
c++笔试题汇总
2011-10-23 16:11 684(转自http://blog.csdn.net/dongfen ... -
c++中使用引用传递来提高效率
2011-10-23 14:37 904(转自:http://www.diybl.com/course ... -
[转] HTTP multipart/form-data 上传方式说明
2011-10-15 06:08 1311( From: http://home.meegoq.co ... -
Multipart uploading spec
2011-10-15 06:07 677Upload File: abc.txtContent:abc ... -
【转】Webcam Manipulation with Javascript
2011-10-15 06:04 805( From:http://blog.trumpton.org ... -
GTK+ 中文显示解决方案
2011-10-15 06:01 655(转自:http://www.wangchao.net.cn/ ... -
Table单元格td的position:relative的兼容性
2011-10-11 12:35 1912( From: http://www.itref.cn/a/ ... -
a lib: jXHR (JSON-P XHR)
2011-10-11 12:18 699http://mulletxhr.com/ -
GTK+主循环(main loop)的工作原理
2011-10-11 11:59 1108GTK+主循环(main loop)的工作原理 转 ...
相关推荐
在Silverlight应用中,与服务器的数据交互是必不可少的,而json-rpc(JSON Remote Procedure Call)则提供了一种轻量级的、高效的通信方式。 **一、理解json-rpc** json-rpc是一种基于JSON(JavaScript Object ...
JSON(JavaScript Object Notation)是一...至于`RemoteService`,这可能是服务端提供的一个接口名称,用于提供JSON或JSONP数据服务。在实际项目中,开发者可能需要根据这个接口来构建前端请求,获取并处理返回的数据。
安装以 root 身份,将这两个文件复制到 ISPConfig 文档...只需添加一个回调查询参数即可触发 JSONP要求JSON 请求是普通的表单编码 POST 请求,其方法是作为 URL 查询参数执行的,名为 method(即 /remote/json.php?meth
http://bob.ippoli.to/archives/2005/12/05/remote-json-jsonp/ http://api.jquery.com/jQuery.ajax/ http://en.wikipedia.org/wiki/JSONP ...
JSON-RPC(JavaScript Object Notation Remote Procedure Call)是一种轻量级的远程过程调用协议,主要应用于客户端与服务器之间的通信,特别是在Web服务中。它的设计灵感来源于XML-RPC,但采用了JSON作为数据交换...
**jqGrid:四、remote data (JSON)** jqGrid是一款基于jQuery的开源表格插件,它提供了丰富的功能,包括数据网格展示、编辑、排序、筛选等。在远程数据(remote data)模式下,jqGrid能够从服务器获取JSON格式的...
例如,JSONP(JSON with Padding)是一种常见的跨域RPC解决方案,通过动态创建`<script>`标签来加载返回JSON数据的服务器脚本。 现代JavaScript RPC的实现更多地依赖于WebSocket,它提供了全双工、低延迟的通信通道...
As of jQuery 1.2, you can load JSON data located on another domain if you specify a JSONP callback, which can be done like so: "myurl?callback=?". jQuery automatically replaces the ? with the correct ...
$.get('http://example.com/remoteService?name=jxq&email=feichexia@yahoo.com.cn&jsonpcallback=?', function(json) { console.log(json.Name); console.log(json.Email); }); ``` 在这种情况下,服务器仍然...
-- WARNING: 允许JSON-RPC连接会绕过DWR提供的大部分安全保护,请谨慎使用 --> <init-param> <param-name>jsonRpcEnabled</param-name> <param-value>true</param-value> </init-param> <!-- WARNING: 允许...
JSONP(JSON with Padding)是一种规避同源策略的方法,它通过动态创建 `<script>` 标签来加载服务端返回的JavaScript代码,该代码会调用一个预先定义好的回调函数并传递数据。 以下是一个简单的jQuery跨域Ajax请求...
例如,当涉及到跨域请求时,JQuery 会利用 `<script>` 标签的特性,以 JSONP(JSON with Padding)的方式实现跨域数据交换。 在处理返回的数据时,JQuery 提供了 `success` 回调函数,可以在数据成功返回后进行处理...
- **JSONP(JSON with Padding)**:跨域数据获取策略,适用于不支持 CORS 的情况。 - **AJAX**:无刷新地与服务器交换数据,实现页面部分更新。 4. **事件处理** - **事件监听(Event Handling)**:绑定各种组件的...
然而,为了实现数据交互,开发者们发明了各种跨域解决方案,其中jQuery库中的JSONP(JSON with Padding)就是一种常用的解决方式。本文将详细介绍如何使用jQuery实现跨域,以及其工作原理。 首先,我们要理解JSONP...
这些方法通常会从数据库或其他数据源获取数据,然后将其转化为适合图表展示的格式,如JSON。 3. **DWR接口暴露**: - 在`dwr.xml`中,声明刚刚创建的Java类和方法,使得它们可以通过DWR被JavaScript调用。 4. **...
- 使用EXTJS的远程分页(remote paging)模式,服务器根据`start`和`limit`返回对应数据,同时提供总记录数,以避免一次性加载大量数据。 6. **实际项目应用**: - 在实际项目中,可以将这个分页示例作为基础,...
JSONP (JSON with Padding) JSONP 是一种古老的跨域解决方案,它利用 `<script>` 标签不受同源策略限制的特点。JSONP 的核心是动态创建 `<script>` 标签,并设置 `src` 属性指向跨域的 API 接口,同时提供一个回调...