简体   繁体   English

使用jquery iframe-transport调用服务的另一个域

[英]Using jquery iframe-transport to call a service another domain

I can't seem to find a good answer to this and I have tried everything. 我似乎找不到很好的答案,我已经尝试了一切。 I am using the JQuery.iframe-transport plugin to do a file upload. 我正在使用JQuery.iframe-transport插件来上传文件。 The problem is that I am uploading to an API on our QA server, qa.company.com , from my local server, localhost:8080 . 问题是我要从本地服务器localhost:8080上传到质量检查服务器qa.company.com上的API。 It appears that the upload is fine but then the plugin errors out when it is trying to read the contents of the iframe it created. 看来上传很好,但是当插件尝试读取其创建的iframe内容时,插件就会出错。

Error: Permission denied to access property 'document' 错误:拒绝访问属性“文档”的权限

var doc = this.contentWindow ? this.contentWindow.document :
            (this.contentDocument ? this.contentDocument : this.document),

It looks like a permissions error trying to read the iframe document variable since it is from a different domain. 尝试读取iframe文档变量似乎是权限错误,因为它来自其他域。 Any ideas on how I can work around this? 关于如何解决此问题的任何想法?

While you can't use the iframe hack crossdomain and read the content of the frame, i think you can bind the onLoad callback to atleast know something happened..... 虽然您不能使用iframe hack跨域并读取框架的内容,但我认为您可以将onLoad回调绑定到至少知道发生了什么事.....

The more modern techy solution to this issue is to send CORS heads from you qa server, which would allow you to push to another domain without using an iframe at all. 解决此问题的更现代的技术解决方案是从qa服务器发送CORS头,这将使您无需使用iframe就可以推送到另一个域。

https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS https://developer.mozilla.org/zh-CN/docs/HTTP/Access_control_CORS

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

相关问题 从iframe访问另一个域的jQuery - Access jQuery from iframe with another domain 使用jquery从另一个域通过Windows身份验证访问WCF服务 - Accessing WCF Service with windows authentication from another domain using jquery 使用jQuery Iframe传输插件发送文件和数据 - Sending files and data using jQuery Iframe transport plugin 使用jQuery定位iFrame主体(相同域) - Target iFrame Body Using jQuery (Same Domain) 无法在IE8-11中的其他域中使用jQuery访问iframe - Can't access iframe using jQuery in another domain In IE8-11 使用jQuery模拟链接的点击-在iframe之外,哪个链接指向另一个域? - Using jQuery to simulate the click of a link - outside of an iframe, which links to another domain? jQuery跨域调用REST服务 - jQuery cross domain call to REST service jQuery Ajax对WebService的调用在IE8中返回“No Transport”错误 - 没有CROSS-DOMAIN - jQuery Ajax Call to WebService returns “No Transport” error in IE8 - NO CROSS-DOMAIN 我们可以使用跨域中的Jquery $ .ajax()调用通过https访问WCF服务吗? - Can we access WCF service over https using Jquery $.ajax() call in cross domain? 如何通过使用javascript和jquery调用asp.net的跨域Web服务 - How to call cross domain web service of asp.net by using javascript and jquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM