我正在尝试通过javascript与我的本地neo4j数据集进行交互。但是我得到了这个错误:
Uncaught SyntaxError:意外的令牌:(13:20:43:754 |错误,javascript) at http://localhost:7474/?callback=jQuery111107695061936974525_1417522841327& {%22statements%22:[{%22statement%22:%22MATCH%20(n)%20RETURN%20count(n)%22}]}& _ = 1417522841328:2 成功(13:20:43:958) at public_html / index.html:34
即。我想通过Web应用程序发送和接收查询。 这是我现在的代码:
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script language="javascript" type="text/javascript" src="js/jquery-1.11.1.js"></script>
<script type="text/javascript">
var body = JSON.stringify({
statements: [{
statement: 'MATCH (n) RETURN count(n)'
}]
});
$.ajax({
url: "http://localhost:7474",
type: "POST",
data: body,
dataType: "jsonp",
contentType: "application/jsonp"
})
.done(function(result){
console.log(result);
})
.fail(function(error){
console.log(error.statusText);
}); </script>
</head>
答案 0 :(得分:2)
由于您正在向错误的端点发布信息,因此无法正常工作。请注意您的网址
应该是这样的:
$.ajax({
url: "http://localhost:7474/db/data/transaction/commit",
type: "POST",
data: body,
dataType: "jsonp",
contentType: "application/jsonp"
})