[早期版本已更新,因为我正在尝试一些东西]
我知道一些javascript,并且我有一个可以在控制台中使用cypher查询的工作neo4j数据库。此外,此curl命令有效:
curl -X POST http://
localhost:7474/db/data/cypher
--data @test.json -H accept:application/json -H content-type:application/json -H X-Stream:true
但是我想通过jQuery $ajax调用获取结果--实际上,任何可以在javascript中获取JSON结果的方式都可以,不必是jQuery。
这个函数会产生以下消息:
500意外字符('q'(代码113)):预期有效值(数字、字符串、数组、对象、'true'、'false'或'null')[来源: java.io.StringReader@56f31ac6; line:1, column: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();