Trello - 引用客户端.js文件,无法在 Trello.authorize API 中调用类型 "Success" 的函数



我正在遵循提到的示例@jsfiddle

当我在单独的HTML,Javascript和CSS中复制相同的代码时,相同的代码不起作用。

.HTML:

              <head>             
       <script src="jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="https://api.trello.com/1/client.js?key=apllication key"></script>
       <script type="text/javascript" src="script.js"></script>
        <link rel="stylesheet" href="base.css" type="text/css" media="screen" charset="utf-8" />                        
        <!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">                </script> -->
       </head>
           <body>
  <div id="loggedout">
      <a id="connectLink" href="#">Connect To Trello</a>
 </div>
  <div id="loggedin">
   <div id="header">
    Logged in to as <span id="fullName"></span> 
    <a id="disconnect" href="#">Log Out</a>
   </div>
   <div id="output"></div>
  </div>

脚本.js内容:

   $(document).ready(function(){
      alert('Welcome to StarTrackr! Now no longer under police investigation!');
         console.log("alert printed");

 $("#connectLink")
   .click(function(){
      Trello.authorize({
                type:"popup",
               name: "from link",
                success: function() {
               alert("in success");
        },
               error:function() {
               alert("in error");
              }
              })
          });

});

在成功时,我想编写我的函数,但它似乎没有调用它。我错过的任何东西。

我遇到了同样的问题,发现这是因为我试图从file:// URL 授权。

不了解确切原因,但在这种情况下,授权页面不会重定向或关闭弹出窗口。

我只是通过使用网络服务器在本地主机上提供我的页面来解决这个问题(我在模块中使用了nodejs serve-static)。

我猜您正在测试的浏览器是IE。

我在 API 中遇到了类似的问题,弹出窗口不调用 OnSuccess 函数,但在 jsFiddle 中工作正常,这似乎是您在这里遇到的问题。

我的解决方案是将类型更改为"重定向",以便它在同一窗口中请求权限。此方法在IE中与单独的文件一起使用。

 $("#connectLink").click(function() {
   Trello.authorize({
     type:"redirect",
     name: "from link",
     success: function() {
       alert("in success");
      },
      error:function() {
        alert("in error");
      }
    })
  });

最新更新