[英]How can I query Neo4j by a user input value ? (Javascript)
I am wondering why this code doesnt do what I want, and that is : 我想知道为什么这段代码没有做到我想要的,那就是:
I have a input tag with id = 'input1', and when the user presses the search button, I want to take that value to specify the name in the neo4j query. 我有一个id为'input1'的输入标签,当用户按下搜索按钮时,我想使用该值在neo4j查询中指定名称。 But now I get empty brackets in my console ([]) instead of, for example, the node with name: Emil This is what I have so far:
但是现在,我在控制台([])中出现了空括号,而不是例如名称为Emil的节点:
<input type="text" id="input1" />
<button onclick="myJsFunction()">Search</button>
function myJsFunction(){
var body = JSON.stringify({
statements: [{
statement: " MATCH (n {name: '" + document.getElementById('input1').value + "´}) RETURN n"
}]
});
$.ajax({
url: "http://localhost:7474/db/data/transaction/commit",
type: "POST",
data: body,
dataType: "json",
contentType: "application/json"
})
.done(function(result){
console.log(result.results);
})
.fail(function(error){
console.log(error.statusText);
});
} }
Any help would be appreciated cuz I am stuck for now. 任何帮助将不胜感激,因为我暂时还停留。
In your query the single quotes (for the name parameter) do not match. 在查询中,单引号(对于name参数)不匹配。 You are opening with [ ' ] but closing with [ ` ].
您以[']开头,但以[`]结束。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.