不安全的JavaScript尝试访问框架,当尝试上传文件与阿贾克斯不安全、上传文件、框架、阿贾克斯

2023-09-10 17:06:44 作者:无名指的忧伤

我的目标是上传文件Ajax的方式。 我用这个JavaScript库 http://valums.com/wp-内容/上传/ Ajax的上传/演示jquery.htm

My goal is to upload file with ajax-way. I use this javascript library http://valums.com/wp-content/uploads/ajax-upload/demo-jquery.htm

在上有我的网页就像一个链接上传按钮上的示例页面。 当我点击它,打开文件对话框打开。 在我选择的文件和表单自动提交。

这是我的javascript code。

var upload_btn = $('#upload-opml');
  new AjaxUpload(upload_btn.attr('id'), {
    action: upload_btn.attr('href'),
    name: 'opml',
    onComplete: function (file, response) {
      //
  }
});

这是服务器code。在Ruby on Rails的。

def upload_opml
    render :text => 'hello'
end

接头,从萤火虫拍摄。

>> Response headers
Server  nginx/0.7.62
Date    Wed, 09 Jun 2010 19:03:28 GMT
Content-Type    text/html; charset=utf-8
Connection  keep-alive
Etag    "5d41402abc4b2a76b9719d911017c592"
X-Runtime   18
Content-Length  5
Cache-Control   private, max-age=0, must-revalidate
Set-Cookie  _RssWebApp_session=BAh7CDoPc2Vzc2lvbl9pZCIlMzJhMTQ0ZWZhOGM3YmIwODFhZmFmNjkwYTI1YWQ2ZjQ6EF9jc3JmX3Rva2VuIjEvZHVzdm1NOVlMTUF6bEw3cGRFT2I3RzZvcVJZUU42bCtMNS9PVVYrNHdBPToMdXNlcl9pZGkG--13f1950a9530591881404fbfab7b1246f98f0d81; path=/; HttpOnly

>> Request headers
Host    readbox.cz
User-Agent  Mozilla/5.0 (X11; U; Linux i686; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language ru,en-us;q=0.7,en;q=0.3
Accept-Encoding gzip,deflate
Accept-Charset  windows-1251,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
Referer http://readbox.cz/view
Cookie  _RssWebApp_session=BAh7CDoPc2Vzc2lvbl9pZCIlMzJhMTQ0ZWZhOGM3YmIwODFhZmFmNjkwYTI1YWQ2ZjQ6EF9jc3JmX3Rva2VuIjEvZHVzdm1NOVlMTUF6bEw3cGRFT2I3RzZvcVJZUU42bCtMNS9PVVYrNHdBPToMdXNlcl9pZGkG--13f1950a9530591881404fbfab7b1246f98f0d81; login=1; APE_Cookie=%7B%22frequency%22%3A11%7D; show-tsl=0

但在Firefox中,我得到一个错误

But in Firefox I get an error

:!?@ 8 BC http://readbox.cz (document.domain的=的 http://readbox.cz )> B:070 => 2 @ 07 @ 5H5 = 88 = 0>; CG5 = 85 A2> 9AB20 HTMLDocument的.readyState 87 http://readbox.cz (document.domain的= 5 1K; CAB0 => 2; 5 =)。 [打破这个错误]如果(doc.readyState&安培;&安培;!doc.readyState ='完整'){

!:@8?BC http://readbox.cz (document.domain=http://readbox.cz) >B:070=> 2 @07@5H5=88 =0 ?>;CG5=85 A2>9AB20 HTMLDocument.readyState 87 http://readbox.cz (document.domain =5 1K; CAB0=>2;5=). [Break on this error] if (doc.readyState && doc.readyState != 'complete') {

在谷歌浏览器

不安全的JavaScript尝试从访问帧网址 http://readbox.cz/subscriptions/upload_opml 帧网址 http://readbox.cz/view#/posts/all 。域,协议和端口必须匹配。 /javascripts/ajaxupload.js?1276107673:574 未捕获的类型错误:无法读取的未定义的属性'readyState的

Unsafe JavaScript attempt to access frame with URL http://readbox.cz/subscriptions/upload_opml from frame with URL http://readbox.cz/view#/posts/all. Domains, protocols and ports must match. /javascripts/ajaxupload.js?1276107673:574 Uncaught TypeError: Cannot read property 'readyState' of undefined

域readbox.info指向127.0.0.1。它的发展。的

推荐答案

我有同样的问题,我解决它编辑ajaxupload库,这个承诺:

I had the same problem and I fix it editing the ajaxupload library, with this commit:

的https://github.com/felipelalli/ajax-upload/commit/9307f5eb6ded1ec63eac828a7ef4b8187acb9617

我已经发出了拉请求给笔者。

I already sent a pull request to the author.

我有这个问题时,我用的是沙盒开发环境(的OpenSocial为Orkut的)。我刚才检查,如果文档是不确定的。上传工作正常,但回调,现在还没有答案(答案是不确定的)。

I had this problem when I was using the sandbox developer environment (opensocial for Orkut). I just check now if "doc" is undefined. The upload works fine, but the callback now has no answer (the answer is undefined).

我不知道到底是什么原因,但我认为这是某种形式的开发环境的限制。

I don't know exactly what is the cause, but I think it is some kind of limitation of the dev environment.

如果你想下载的补丁,请检查出来:的https:/ /github.com/felipelalli/ajax-upload/commits/3.9.1

If you want to download the fix, please check it out: https://github.com/felipelalli/ajax-upload/commits/3.9.1