问题标签 [jsonp]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1018 浏览

javascript - 注入 JQuery 跨域

使用 JsonP 注入 JQuery 的脚本是否安全?

我的网络应用程序的安装是 - 将脚本添加到客户的网站(如谷歌分析)。我正在考虑在客户的网站上使用 JQuery,作为我自己注入脚本的一部分。

我想知道,是否存在某种风险?该应用程序需要支持任何类型的网站。

谢谢亚龙

0 投票
3 回答
671 浏览

javascript - MooTools JSONP 请求不适用于无效密码

我使用 MooTools 发出 JSONP 请求:

使用有效的登录名和密码,它可以正常工作(提醒我success)。
当我更改password为无效值时,它不会做任何事情。
我不知道为什么它表现不好。
当我使用Request.JSON(). 有任何想法吗 ?

0 投票
10 回答
554217 浏览

javascript - 什么是 JSONP,为什么要创建它?

我了解 JSON,但不了解 JSONP。维基百科关于 JSON 的文档是(曾经)JSONP 的最高搜索结果。它是这样说的:

JSONP 或“带填充的 JSON”是 JSON 扩展,其中前缀被指定为调用本身的输入参数。

嗯?什么电话?这对我来说没有任何意义。JSON 是一种数据格式。没有电话。

第二个搜索结果来自某个名叫Remy的人,他写了这个关于 JSONP 的内容:

JSONP 是脚本标签注入,将来自服务器的响应传递给用户指定的函数。

我可以理解这一点,但它仍然没有任何意义。


那么什么是 JSONP?为什么创建它(它解决了什么问题)?我为什么要使用它?


附录:我刚刚在 Wikipedia上为 JSONP 创建了一个新页面;它现在根据jvenema的回答对 JSONP 进行了清晰而全面的描述。

0 投票
1 回答
260 浏览

jquery - 发布 HTML 标头中显示的 JSON 数据

在一个站点上使用 Firebug,我注意到这个 JSON POST 请求:

问题是知道他们使用的是 jQuery、jsonrpc 和 polopoly cms,是否可以发布相同的 JSON 数据但从我的网络服务器上托管的页面?

0 投票
1 回答
646 浏览

wcf - C# WCF 在企业防火墙内部工作,但不在外部

我的 WCF JSONP Web 服务遇到了一个“有趣的”错误。它是我唯一拥有的,它只公开一种方法。如果我在内部通过 Web 浏览器访问我的服务,它会弹出一条消息,实际上 MEX 未启用(真)。如果我从我们的网络外部点击它(就像你会,除非你在我公司的一台机器上)它只是坐在那里,最后超时。URL 是:http ://demo.rivworks.com/services/Negotiate.svc 。关于可能导致这种行为的任何想法?

这是web.config:

这是代码:

我在这里做了几件事:

  1. 为什么我不能从本地网络外部访问它?
  2. 如何让 MEX 正常工作

注意:我正在使用此处找到的 JSONP 类:http: //msdn.microsoft.com/en-us/library/cc716898.aspx

0 投票
1 回答
1146 浏览

php - JSONP PHP 会话不会保持不变

在网站上使用 JSONP,比如 xyz.com,我正在调用网站 abc.com/test.php。但是,每次我调用这个站点时,我都会在 IE6 和 IE7 中获得一个新的会话 ID。在其他浏览器中它保持不变。

test.php 的代码类似于:

但是,在我在另一个窗口中访问http://abc.com/test.php,然后使用 JSONP 代码刷新我在 xyz.com 的页面后,它会显示一个常量 ID。我不知道为什么。有什么建议么?

这只发生在 IE6 和 IE7 中。按预期休息所有工作。不知何故,IE6 和 IE7 不会缝合以保留会话 ID(即 cookie 名称),直到我在另一个窗口中实际访问该站点。

0 投票
3 回答
6831 浏览

php - jsonp -> json_decode()

由于某种原因,我无法从返回的 jsonp 字符串中获取信息,

// ★✩ 为什么下一行不起作用?

这是我的结果

komputilojhttp://vortaro.us.to/ajax/epo/eng/komputiloj/?callback=

({"text":"komputilo: 计算机"})

json_decode 设置AV内容

不是空的

我应该看到 echo $AVDecode

0 投票
3 回答
4978 浏览

php - Cross Domain ajax and php sessions

I'm baffled by this one... I'm doing a remote widgety type of setup, we'll control both domains so security is not a concern. I'm using jsonp to allow cross domain ajax requests.

The visited site is domain1.com, which inclues:

file.js uses jQuery to make ajax requests:

It goes through several of these steps in somewhat of a wizard, reloading the div with html from the remote server.

The problem I'm running into is that on each ajax request, I get a new php session id and my session data goes away. The PHP end of things is fine, if I run the same script from the same domain (still using jsonp), everything works fine. Doing it from a remote domain, however, and the session does not stick around. I have no idea why this is, the php end is setting and requesting a cookie from it's own domain. I do not need to access the cookie from JS. The cookie is being written and saved on the server. But each request when I check the stored cookies in the browser, the session id has changed.

Any ideas?

0 投票
4 回答
4788 浏览

web-services - 在线 JSONP 转换器/包装器

我想获取文件源并将其包装在JSONP中。

例如,我想从我不拥有的主机中检索pets.txt作为文本。我想通过只使用客户端 JavaScript 来做到这一点。

我正在寻找可以将任何内容转换为 JSONP 的在线服务。


YQL

雅虎查询语言就是其中之一。

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D"http://elv1s.ru/x/pets.txt"&format=json&callback=grab

如果 URL 未被 robots.txt 阻止,则此方法有效。YQL尊重 robots.txt。我无法获取http://userscripts.org/scripts/source/62706.user.js因为它被robots.txt阻止了。

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D"http://userscripts.org/scripts/source/62706.user.js"&format=json&callback=grab

"forbidden":"robots.txt 域不允许抓取 url: http://userscripts.org/scripts/source/62706.user.js "


所以我正在寻找另一种解决方案。

0 投票
1 回答
1615 浏览

.net - 通过 SSL/HTTPS 使用 jsonp 和 .NET Web 服务的跨域 AJAX

我正在使用下面的示例使用 .net Web 服务和 jquery 进行跨域 ajax 调用。 http://bloggingabout.net/blogs/adelkhalil/archive/2009/08/14/cross-domain-jsonp-with-jquery-call-step-by-step-guide.aspx

在我尝试将端点更改为 https 之前,它工作正常。我没有收到任何错误,只是没有响应。我的第一个问题是,它甚至可以用 jsonp 做吗?如果是这样,我将不胜感激有关如何解决/解决问题的指导。

谢谢!