2011-11-16 78 views
0

我嘗試使用下面的代碼:處理JS/jQuery的/ AJAX - 無法加載草圖

$('#clicker').click(function(){ 
    var canvasRef = $('<canvas id="project_canvas"/>'); 
    var p = Processing.loadSketchFromSources(canvasRef, '/anything.pde'); 
    $('#loader').append(canvasRef); 
}); 

要加載處理JS的草圖使用jQuery/Ajax和它做奇怪的事情 - 嘗試打破/anything.pde的所有字符拋出此錯誤:

GET http://localhost:8888/a 404 (Not Found) 
GET http://localhost:8888/n 404 (Not Found) 
GET http://localhost:8888/n 404 (Not Found) 
GET http://localhost:8888/y 404 (Not Found) 
GET http://localhost:8888/t 404 (Not Found) 
GET http://localhost:8888/h 404 (Not Found) 
GET http://localhost:8888/i 404 (Not Found) 
GET http://localhost:8888/g 404 (Not Found) 
GET http://localhost:8888/p 404 (Not Found) 
GET http://localhost:8888/d 404 (Not Found) 
GET http://localhost:8888/e 404 (Not Found) 

任何想法是怎麼回事?

回答

1

應通行證作爲數組:

var p = Processing.loadSketchFromSources(canvasRef, ['/anything.pde']); 

正如名字所示,loadSketchFromSources,來源,你可以通過多個源作爲數組。

+1

很好 - 謝謝 - 這個功能在哪裏有記錄?你知道如何設置回調函數嗎? – mheavers