[随着我的尝试,早期版本已更新]
我确实知道一些 javascript,并且我有一个可用的 neo4j 数据库,我可以在控制台中使用 cypher 进行查询。另外,这个卷曲也有效:
卷曲 -X POST http://localhost:7474/db/data/cypher
--data @test.json -H
接受:应用程序/json -H 内容类型:应用程序/json -H
X 流:true
但我想通过 jQuery $ajax 调用获得结果——实际上,任何我可以在 javascript 中获得 JSON 结果的方法,不一定是 jQuery
该函数产生消息:
500 意外字符('q'(代码 113)):预期有效值
(数字、字符串、数组、对象、'true'、'false' 或 'null')位于 [来源:
java.io.StringReader@56f31ac6;行:1,列:2]
提前致谢,
卡尔
function getsomething() {
var serverURL = "http://localhost:7474/db/data"
$.ajax({
type:"POST",
url: serverURL + "/cypher",
accepts: "application/json",
dataType: "json",
contentType:"application/json",
headers: {
"X-Stream": "true"
},
data:{ "query" : "start n = node(1) return n;" },
success: function(data, textStatus, jqXHR){
alert(textStatus);
},
error: function(jqXHR, textStatus, errorThrown){
alert(errorThrown);
console.log(textStatus);
}
});//end of ajax
} //end of getSomething()
getsomething();
您需要使用HTTP方法POST
交谈db/data/cypher
端点。所以尝试设置
type: "POST",
在你的电话中$.ajax
.
免责声明:我自己没有尝试过,只是一时兴起
update
你需要使用包装数据部分JSON.stringify
:
data: JSON.stringify({
"query" : "start n = node(*) return n;",
"params" : {}
}),
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)