将数据发布到 JsonP [英] Post data to JsonP

查看:25
本文介绍了将数据发布到 JsonP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将数据发布到 JsonP?还是所有数据都必须作为 GET 请求在查询字符串中传递?

Is it possible to post data to JsonP? Or does all data have to be passed in the querystring as a GET request?

我有很多数据需要发送到服务,跨域,而且数据太大,无法通过查询字符串发送

I have alot of data that I need to send to the service, cross domain, and it is too large to send via the querystring

解决这个问题有哪些选择?

What are the options for getting around this?

推荐答案

不可能对另一个域上的服务执行异步 POST,因为同源政策.JSON-P 之所以有效,是因为您可以将 <script> 标签插入到 DOM 中,并且它们可以指向任何地方.

It is not possible to do an asynchronous POST to a service on another domain, due to the (quite sensible) limitation of the same origin policy. JSON-P only works because you're allowed to insert <script> tags into the DOM, and they can point anywhere.

当然,您可以将另一个域上的页面设为常规表单 POST 的操作.

You can, of course, make a page on another domain the action of a regular form POST.

编辑:有一些有趣的 hacks 如果您愿意付出大量努力插入隐藏的