【问题标题】:Trello API Post new card error - Failed to execute 'postMessage' on 'DOMWindow'Trello API 发布新卡错误 - 无法在“DOMWindow”上执行“postMessage”
【发布时间】:2016-11-30 05:42:36
【问题描述】:

我正在尝试按照教程并在我的 Trello 板列表中创建一张新卡。

我从这里得到我的钥匙https://trello.com/app-key 按照本教程https://developers.trello.com/get-started/start-building 我在单独的选项卡中打开了我的板。并尝试了公共和私人模式。

但是,我得到了

在“DOMWindow”上执行“postMessage”失败:目标来源 提供的 ('file://') 与收件人窗口的来源不匹配 ('null')。

可能是什么问题?

这是我的代码:

  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>

  <script src="https://api.trello.com/1/client.js?key=MyKey"></script>



  <body>
     <script>




       var authenticationSuccess = function() { console.log('Successful authentication'); };
       var authenticationFailure = function() { console.log('Failed  authentication'); };


Trello.authorize({
    type: 'popup',
    name: 'Getting Started Application',
    scope: {
    read: true,
    write: true },
    expiration: 'never',
    success: authenticationSuccess,
    error: authenticationFailure
});

  var myList = 'Mylist';
  var creationSuccess = function(data) {
  console.log('Card created successfully. Data returned:' + JSON.stringify(data));
};

  var newCard = {
  name: 'New Test Card', 
  desc: 'This is the description of our new card.',
  // Place this card at the top of our list 
  idList: myList,
  pos: 'top'
};

Trello.post('/cards/', newCard, creationSuccess);

  </script>

【问题讨论】:

    标签: javascript api dom postmessage trello


    【解决方案1】:

    我发现了问题。您必须从服务器而不是从本地文件系统执行它。就是这么简单。

    【讨论】:

      猜你喜欢
      • 2018-11-24
      • 2018-05-29
      • 2018-05-30
      • 2016-12-11
      • 2019-11-05
      • 2019-12-09
      • 1970-01-01
      • 2018-05-27
      相关资源
      最近更新 更多