我在弄清楚如何让 OrientDB JavaScript API 在 Web 应用程序中工作时遇到了一些困难。
我尝试搜索 OrientDB Studio Web 应用程序的源代码,并注意到他们使用 orientdb JavaScript API 和一些 AngularJS,这看起来非常迷人,但随后我尝试通过创建一个简单的网页导入orientdb-api.js 和 jquery 库,它没有工作。
这是我网页的内容:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="orientdb-api.js"></script>
<title></title>
<script>
function connect() {
var orientdb = new ODatabase("http://localhost:2480/GratefulDeadConcerts");
var orientdbinfo = orientdb.open();
}
</script>
</head>
<body>
<input type="button" value="Connect to OrientDB" onclick="connect()"/>
</body>
</html>
我在我的 JS 中使用 localhost,但在我看来,从客户端访问我在服务器上的 orientdb 数据库是没有意义的。我想我遗漏了一些东西,但我仍然很想将 JS API 用于 OrientDB。我应该使用 Node.js 之类的东西还是独立的 JS 文件就足够了?
当我在随附的 HTML 文件中运行 JS 代码时收到此错误消息。
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:2480/database/GratefulDeadConcerts. This can be fixed by moving the resource to the same domain or enabling CORS.
任何帮助、建议或资源将不胜感激。
问候, 杰里米