我的processing.js草图没有加载。这不应该太难回答

时间:2010-11-21 02:35:39

标签: javascript html processing.js

我想对我刚刚移植到processing.js的草图进行测试。当我加载网页时,我从Chrome中的javascript控制台收到以下错误:

  

XMLHttpRequest无法加载file:///Users/aoeuaoeu/Desktop/projects/local%20site%20files/_/ee.pde。 Access-Control-Allow-Origin不允许使用null。   processing.js:27未捕获错误:NETWORK_ERR:XMLHttpRequest异常101

这是我正在加载的页面的来源:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Earnest Emporium</title>
<!--Contact: earnestemporium@gmail.com--> 
<script src="processing.js"></script>   
<canvas data-processing-sources="ee.pde"></canvas>  
</head>
<body>
</body>
</html>

ee.pde和processing.js与html文件位于同一目录中,所以我不确定发生了什么。我还应该指出,我正在本地测试这个,当我上传到我的ftp服务器上加载页面时出现了不同的错误。 (也许它是chrome?我得到一个黑盒子,一旦它上传到ftp服务器就不会出现在firefox上的chrome上。它可以在firefox本地工作正常)

 /processing.js:17946Uncaught SyntaxError: Unexpected token <
Processing.Sketch.attach/processing.js:17946
Processing.Processing.executeSketch/processing.js:16209
Processing/processing.js:16237
init/processing.js:17991
window.addEventListener.i

1 个答案:

答案 0 :(得分:7)

我刚注意到这一点:

file:///Users/aoeuaoeu/Desktop/projects/local%20site%20files/_/ee.pde.

您是否在桌面上运行此功能?如果我没记错 AJAX 从桌面运行 NOT ,则需要设置本机Web服务器,并通过调用localhost运行它。