“错误":“无效来源"使用保管箱选择器 [英] "error": "Invalid origin" using dropbox chooser

查看:122
本文介绍了“错误":“无效来源"使用保管箱选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<!DOCTYPE html>
<html>
<head>
 <title>DropBox Chooser Example</title>
</head>
<body>
 <div id="main">
  <input type="dropbox-chooser" name="selected-files" data-link-type="direct" id="db-chooser"/>
  <div id="content"></div>
 </div>

<script type="text/javascript" src="https://www.dropbox.com/static/api/1/dropins.js" id="dropboxjs" data-app-key="YOUR-APP-KEY"></script>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="jquery.tools.min.js"></script>
<script type="text/javascript" src="jquery-layout.js"></script>
<script type="text/javascript">

$(function(){

    var dbChooser = $("#db-chooser");

    dbChooser.on("DbxChooserSuccess", function(e) {

        // Here we will listen when a file is
        // chosen from dropbox, insert it into the page
        // and initialize the Jcrop plugin
        e = e.originalEvent;
       var name = e.files[0].name;
    });
});
</script>
</body>
</html>

这是我尝试实现Dropbox选择器的示例代码.我已经创建了一个应用,并且确实通过了应用密钥.我遇到的错误是

This is my example code in which i am trying to implement the dropbox chooser. I have created an app and i do pass the app key. The errors i encounter are,

  1. 最初在页面加载时,我得到了$(...).on不是函数的错误.

  1. Initially on page load, i get the error that $(...).on is not a function.

当我单击保管箱选择器按钮时,出现{错误":无效来源"}.

When i click on the dropbox chooser button, i get {"error": "Invalid origin"}.

我没有弄错我要去的地方.任何帮助将不胜感激.

I am not getting where i am going wrong. Any help will be appreciated.

推荐答案

我今天遇到并能够解决同一问题.除非脚本在Web服务器上运行,否则Dropbox Chooser功能不支持文件浏览.如果您在本地测试Web应用程序并通过file://链接访问它,则会收到无效来源"错误.相反,运行带有Web应用程序的Web服务器(本地或托管在其他地方),这应该可以消除该错误.

I ran into, and was able to resolve, this same issue today. The Dropbox Chooser functionality does not support file browsing unless the script is running on a web server. If you are testing your web app locally and are accessing it via a file:// link, you will get the 'invalid origin' error. Instead, run a web server (either locally or hosted somewhere else) with your web app on it, and that should eliminate the error.

这篇关于“错误":“无效来源"使用保管箱选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆