I have created a geohash neo4j database for NYC Taxi data. Now the next step is to visualize it within a map, for that i choosed Leaflet as a Javascript library. with static data i can plot geohash data in Leaflet:
but now i want to query that data from the neo4j database and render it.
so is it possible to do that or only with a server side scripting language(node.js,php...) ?
i found a simlair question here , the solution is to query the database with ajax however it dosen't work for me and i get "error" in the console:
var body = JSON.stringify({
statements: [{
statement: 'MATCH (n) RETURN count(n)'
}]
});
$.ajax({
url: "http://localhost:7474",
type: "POST",
data: body,
contentType: "application/json"
})
.done(function(result){
console.log(result);
})
.fail(function(error){
console.log(error.statusText);
});
I find the solution:
first the url for the database is : "http://localhost:7474/db/data/transaction/commit" and not "http://localhost:7474".
then after changing that i got an unauthorized error in console , that means i need to add my user/password to my ajax call, this is done by a function called beforeSend like this:
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa("neo4j"+ ":" + "your_neo4j_password"));
}}
so the final Ajax Solution is :
$.ajax({
url: "http://localhost:7474/db/data/transaction/commit",
type: "POST",
data: body,
contentType: "application/json",
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa("neo4j"+ ":" + "password"));
}}
)
.done(function(result){
console.log(result);
})
.fail(function(error){
console.log(error.statusText);
});