2012-07-16 23 views
1

我正在構建一個將在WebOS中運行並作爲Chrome桌面Web應用程序運行的Campfire客戶端。 我有以下代碼:如何使用Enyo 2.0 WebService對象

logIn: function(){ 
    this.apiToken = this.$.loginScreen.$.apiToken.getValue(); 
    this.subdomain = this.$.loginScreen.$.subdomain.getValue(); 
    this.fullURL = 'https://' + this.subdomain + '.campfirenow.com/'; 
    this.$.roomService.url = this.fullURL + 'rooms.json'; 
    var response = this.$.roomService.send({'Authorization': "Bearer " + this.apiToken, 'Access-Control-Allow-Origin': this.subdomain + '.campfirenow.com'}); 

的 '房間服務' 是這樣的:

{name: "roomService", kind: "enyo.WebService", url: null, onResponse: "successfulAlert", onError: "someFailure"} 

而在鉻我不斷收到以下XMLHttpRequest的錯誤:

Origin null is not allowed by Access-Control-Allow-Origin. 

任何想法?

回答

2

你可能想看看這個StackOverflow的問題:

XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin

你正在阻止試圖從文件中運行以下命令:// URL。

+0

如果您是從服務器運行它,如果Campfire不允許通過AJAX跨站點訪問其API,則可能仍會被阻止*或*用戶的瀏覽器不支持跨站點AJAX語義。 – 2012-07-17 19:27:13

+0

我從Chromium運行並禁用安全功能。也許我可以將一個node.js服務器嵌入到我的應用程序中並以這種方式進行調用?我寧願只是以某種方式使用web服務。 – RedMage 2012-07-24 22:38:32