简体   繁体   English

Javascript:具有客户端网络服务<script> tag

[英]Javascript: client-side webservice with <script> tag

I'm trying to implement sort of client-side webservice client. 我正在尝试实现某种客户端Web服务客户端。

To get over the same server policy , i'm thinking of including the external page whose content I need to read via the <script> tag that can get cross-domain content. 为了克服相同的服务器策略 ,我正在考虑包括外部页面,我需要通过<script>标记读取其内容,以获取跨域内容。 I have no control over the webservice being consumed, so i can't actually return javascript code (it's a simple html page returning "OK" or "KO" in the body). 我无法控制正在使用的Web服务,因此我实际上无法返回javascript代码(这是一个简单的html页面,体内返回“ OK”或“ KO”)。

It seems like I can't use src="text/html", only "text/javascript" is accepted and this yelds an obvious error as an html page can't be evaluated as javascript code. 似乎我不能使用src =“ text / html”,仅接受“ text / javascript”,由于无法将html页面评估为javascript代码,因此产生了明显的错误。

Apart from that, how can I then read the loaded script's content? 除此之外,我该如何读取已加载脚本的内容? With Google Chrome's javascript console I can see that the page is loaded withing the script, only I don't know how to access it. 使用Google Chrome的javascript控制台,我可以看到该页面随脚本一起加载,只有我不知道如何访问它。

PS: I'm using jQuery, if this helps. PS:如果有帮助,我正在使用jQuery。

You can't. 你不能 If this worked, it would expose private (eg protected by cookies) user data to third-party sites. 如果这样做有效,它将向第三方站点公开私有(例如受cookie保护的)用户数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM