0
我一直遇到我的html5 web worker的麻煩。 web worker postMessage()是一個JSON對象,用於調用工作者的文檔級別的JavaScript,它帶有一個onmessage()函數。JSON對象變爲'null'
顯然,「iterationsjob」鍵可以作爲工人可以處理相關的數值訪問,但這似乎只在谷歌Chrome瀏覽器,它仍然引發錯誤:
18Uncaught TypeError: Cannot read property 'iterationsjob' of null
在Firefox中,網絡工作者根本無法工作,也似乎無法訪問數字,我得到了一個成功的ajax調用,但它似乎繞過了日誌記錄步驟,並通過單獨的ajax調用引發了另一個錯誤。 所以我砍死在一起,讓工人數()信息返回到控制檯一個基本途徑,並從工人中調用它們:
var iterations
//get iteration data from the server
p.ajax.post({
url:'/getdataurl',
dataType: "json",
success: function(responseText){
log("test");
log("responseText is "+responseText);
iterations = responseText.iterationsjob;
log("iterations is "+iterations);
}
});
我預計將看到以下內容:
test
responseText is [object Object]
iterations is 3993547
相反,我看到:
test
responseText is [object Object]
iterations is 3993547
test
responseText is null
Uncaught TypeError: Cannot read property 'iterationsjob' of null
有人可以解釋什麼問題,以及如何解決它? 編輯:我已經上傳了源代碼here的zip。在Google App Engine上運行。
謝謝!任何幫助非常感謝。
向我們展示問題的自包含測試用例,而不是散文。 –
可能重複的[jquery蜂巢ajax調用不工作](http://stackoverflow.com/questions/7218297/jquery-hive-ajax-call-not-working) –
哎呀,對不起。自從那篇文章以來,我已經取得了一些進展,並將問題分爲兩個獨立的問題,所以我會投票去除該帖子。 – ejang