[英]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.