Javascript 无法在internet上部署我的程序

Javascript 无法在internet上部署我的程序,javascript,user-interface,processing,Javascript,User Interface,Processing,我已经使用GUI处理库在JavaScript中创建了一个TicTacToe程序。现在我想把它放到一个网站上。允许我们这样做,但尽管做了很多尝试,我似乎无法让它工作 我正在上传我的文件。它包含我的加工草图、我的html文件和Processing.js文件。还包含一个我在算法中使用的文本文件 首先,我尝试使用以下语法直接使用草图: <script src="processing.js"></script> <canvas data-processing-sources

我已经使用GUI处理库在JavaScript中创建了一个TicTacToe程序。现在我想把它放到一个网站上。允许我们这样做,但尽管做了很多尝试,我似乎无法让它工作

我正在上传我的文件。它包含我的加工草图、我的html文件和Processing.js文件。还包含一个我在算法中使用的文本文件

首先,我尝试使用以下语法直接使用草图:

<script src="processing.js"></script> 
<canvas data-processing-sources="anything.pde"></canvas>

但当我这么做的时候,我的浏览器只显示了一个空白页面。接下来,我尝试将所有代码放入processing.js网站上提到的html文件中。当我这样做时,游戏会加载到页面上,我可以移动,但计算机不会按预期移动。我已经对这个程序进行了广泛的测试,它确实在处理IDE中运行

更新: 所以我检查了JavaScript控制台,发现我在程序中使用的posabilities.txt文件没有被加载。以下是控制台的说明:

processing.js:11 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
ajax @ processing.js:11
p.loadStrings @ processing.js:13904
fillStore @ VM56:340
caller @ VM56:164
mouseClicked @ VM56:121
(anonymous) @ processing.js:7613
processing.js:16 Failed to load file:///D:/possibilities.txt: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
ajax @ processing.js:16
p.loadStrings @ processing.js:13904
fillStore @ VM56:340
caller @ VM56:164
mouseClicked @ VM56:121
(anonymous) @ processing.js:7613
processing.js:16 Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///D:/possibilities.txt'.
    at ajax (http://localhost:8081/processing.js:16:9)
    at Processing.Processing.p.loadStrings (http://localhost:8081/processing.js:13904:25)
    at Processing.Processing.fillStore (eval at attach (http://localhost:8081/processing.js:718:22), <anonymous>:340:16)
    at Processing.Processing.caller (eval at attach (http://localhost:8081/processing.js:718:22), <anonymous>:164:3)
    at Processing.Processing.mouseClicked (eval at attach (http://localhost:8081/processing.js:718:22), <anonymous>:121:6)
    at HTMLCanvasElement.<anonymous> (http://localhost:8081/processing.js:7613:9)
ajax @ processing.js:16
p.loadStrings @ processing.js:13904
fillStore @ VM56:340
caller @ VM56:164
mouseClicked @ VM56:121
(anonymous) @ processing.js:7613
processing.js:11[Deprecation]主线程上的同步XMLHttpRequest已被弃用,因为它会对最终用户的体验产生有害影响。如需更多帮助,请查看https://xhr.spec.whatwg.org/.
ajax@processing.js:11
p、 loadStrings@processing.js:13904
fillStore@VM56:340
呼叫者@VM56:164
鼠标单击@VM56:121
(匿名)@processing.js:7613
processing.js:16未能加载file:///D:/possibilities.txt: 跨源请求仅支持协议方案:http、数据、chrome、chrome扩展、https。
ajax@processing.js:16
p、 loadStrings@processing.js:13904
fillStore@VM56:340
呼叫者@VM56:164
鼠标单击@VM56:121
(匿名)@processing.js:7613
processing.js:16 Uncaught DomeException:未能对“XMLHttpRequest”执行“发送”:加载失败file:///D:/possibilities.txt'.
在阿贾克斯(http://localhost:8081/processing.js:16:9)
在Processing.Processing.p.loadStrings处(http://localhost:8081/processing.js:13904:25)
at Processing.Processing.fillStore(eval at attach(http://localhost:8081/processing.js:718:22), :340:16)
at Processing.Processing.caller(eval at attach(http://localhost:8081/processing.js:718:22), :164:3)
at Processing.Processing.mouseClicked(eval at attach(http://localhost:8081/processing.js:718:22), :121:6)
在HTMLCanvasElement。(http://localhost:8081/processing.js:7613:9)
ajax@processing.js:16
p、 loadStrings@processing.js:13904
fillStore@VM56:340
呼叫者@VM56:164
鼠标单击@VM56:121
(匿名)@processing.js:7613
还将该文件托管在本地主机服务器上,并尝试。。还是不走运。控制台显示此错误:

processing.js:11 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
ajax @ processing.js:11
p.loadStrings @ processing.js:13904
fillStore @ VM25:340
caller @ VM25:164
mouseClicked @ VM25:121
(anonymous) @ processing.js:7613
processing.js:16 Failed to load http://localhost:8081/possibilities.txt: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access.
ajax @ processing.js:16
p.loadStrings @ processing.js:13904
fillStore @ VM25:340
caller @ VM25:164
mouseClicked @ VM25:121
(anonymous) @ processing.js:7613
processing.js:16 Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:8081/possibilities.txt'.
    at ajax (file:///D:/web/processing.js:16:9)
    at Processing.Processing.p.loadStrings (file:///D:/web/processing.js:13904:25)
    at Processing.Processing.fillStore (eval at attach (file:///D:/web/processing.js:718:22), <anonymous>:340:16)
    at Processing.Processing.caller (eval at attach (file:///D:/web/processing.js:718:22), <anonymous>:164:3)
    at Processing.Processing.mouseClicked (eval at attach (file:///D:/web/processing.js:718:22), <anonymous>:121:6)
    at HTMLCanvasElement.<anonymous> (file:///D:/web/processing.js:7613:9)
ajax @ processing.js:16
p.loadStrings @ processing.js:13904
fillStore @ VM25:340
caller @ VM25:164
mouseClicked @ VM25:121
(anonymous) @ processing.js:7613
processing.js:11[Deprecation]主线程上的同步XMLHttpRequest已被弃用,因为它会对最终用户的体验产生有害影响。如需更多帮助,请查看https://xhr.spec.whatwg.org/.
ajax@processing.js:11
p、 loadStrings@processing.js:13904
fillStore@VM25:340
呼叫者@VM25:164
鼠标单击@VM25:121
(匿名)@processing.js:7613
processing.js:16未能加载http://localhost:8081/possibilities.txt: 对飞行前请求的响应未通过访问控制检查:请求的资源上不存在“访问控制允许来源”标头。因此,不允许访问源“file://”。
ajax@processing.js:16
p、 loadStrings@processing.js:13904
fillStore@VM25:340
呼叫者@VM25:164
鼠标单击@VM25:121
(匿名)@processing.js:7613
processing.js:16 Uncaught DomeException:未能对“XMLHttpRequest”执行“发送”:加载失败http://localhost:8081/possibilities.txt'.
在阿贾克斯(file:///D:/web/processing.js:16:9)
在Processing.Processing.p.loadStrings处(file:///D:/web/processing.js:13904:25)
at Processing.Processing.fillStore(eval at attach(file:///D:/web/processing.js:718:22), :340:16)
at Processing.Processing.caller(eval at attach(file:///D:/web/processing.js:718:22), :164:3)
at Processing.Processing.mouseClicked(eval at attach(file:///D:/web/processing.js:718:22), :121:6)
在HTMLCanvasElement。(file:///D:/web/processing.js:7613:9)
ajax@processing.js:16
p、 loadStrings@processing.js:13904
fillStore@VM25:340
呼叫者@VM25:164
鼠标单击@VM25:121
(匿名)@processing.js:7613
您需要查看以查看代码抛出的任何错误

无耻的自我提升:我写了一篇关于使用Processing.js部署处理的教程,该教程可用

您还没有发布(请以后尝试发布),因此我无法确切说明发生了什么,但我猜您在代码中使用的是纯Java功能,这会导致JavaScript抛出错误。如果是这样的话,那么您就需要去掉那些Java代码