我正在尝试创建一个可编辑的SlickGrid(使用jquery-ui)并使用Dojo.
当我的页面包含
<script src="../../bower_components/dojo/dojo.js"></script>
<script src="../../bower_components/SlickGrid/lib/jquery-ui-1.11.3.js"></script>
<script src="../../mlads/fillDemo/FillDemo.js"></script>
控制台显示时
Error: multipleDefine
return mix(new Error(error), {src:"dojoLoader", info:info}); dojo.js (line 106)
src: dojoLoader dojo.js (line 1896)
info: Object { pid="dijit", mid="dijit/_WidgetsInTemplateMixin", pack={...}, more...}
Run Code Online (Sandbox Code Playgroud)
如果我注释掉jquery-ui行,那么错误就会消失.
FillDemo.js是我的源代码,它以
require(
[ "dojo/_base/declare",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin",
"dijit/registry",
"dijit/form/Button",
"dijit/form/DropDownButton",
Run Code Online (Sandbox Code Playgroud) 我可以使用curl发布到我的Slack Incoming Webhook:
curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello world"}' https://hooks.slack.com/services/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
Run Code Online (Sandbox Code Playgroud)
但是当我使用时
$.ajax({
url: "https://hooks.slack.com/services/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",
data: '{"text": "Hello world"}',
type: "POST",
contentType: "application/json"
})
.done(function (reply) {
console.log("POST to Slack succeeded")
})
.fail(function (xhr, status, errorThrown) {
console.log("Error in POST to Slack: " + errorThrown.toString())
})
Run Code Online (Sandbox Code Playgroud)
在我的应用程序的localhost:8090服务的页面中,我收到错误:
jquery.js:9536 OPTIONS https://hooks.slack.com/services/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
400 (Bad Request)
XMLHttpRequest cannot load https://hooks.slack.com/services/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.
Response for preflight has invalid HTTP status code 400
Run Code Online (Sandbox Code Playgroud)
通常,我页面上的POST将转到我的服务器,该服务器为页面提供服务.所以我认为我的困惑与理解Webhooks如何工作有关.我认为同源政策禁止我发布到任意网址.但是为什么curl命令工作,我如何让我的页面做curl的工作呢?
我是否需要从服务器发送POST,而不是从客户端浏览器发送?