I ran into issues with dataType "json" and jquery ajax (esp. around CORS).
my code looks like this:
$.ajax(txUrl(), {
type: "POST",
data: JSON.stringify({
statements: [{
statement: query,
parameters: params || {},
resultDataContents: ["row",
"graph"]
}]
}),
contentType: "application/json",
error: function(err) {
cb(err);
},
success: function(res) {
if (res.errors.length > 0) {
...
Am 05.09.2014 um 00:39 schrieb David Bigelow
<[email protected]>:
> OK - This has been pounding my head all day. Here is a simple example that
> has been constructed from multiple help docs, various sites on the net -- but
> mainly from the neo4j docs.
>
> There is a BIG question of when you use the new Transaction vs Cypher URL
> Endpoints -- this is done in 2.1.3 and 2.1.4 -- no difference.
>
> Here is a sample using jQuery and JavaScript:
>
>
> var query_PATHS = "match n where n.name = {startNodeName} return
> distinct n"
>
> var cypherRequest = {
> "params" : {
> "startNodeName": "Node C"
> },
> "query" : query_PATHS
> };
>
> $.ajax(
> {
> url : "http://localhost:7474/db/data/cypher",
> type: "POST",
> data : cypherRequest,
> dataType: "json",
> success: function(obj, textStatus, jqXHR)
> {
>
> console.log('::successfully executed call');
> // data is object returned from server
>
> console.log('FOUND THIS:'+obj);
> console.log(obj);
> console.log(textStatus);
> console.log(jqXHR);
>
> return;
>
>
> nQuery.paths.reducePaths();
>
> },
> error: function(jqXHR, textStatus, errorThrown)
> {
> $('.progress').addClass('hidden');
> $('.noResultsMessage').removeClass('hidden');
>
> console.log(':: FAILED to executed call');
>
> console.log(errorThrown)
> console.log(jqXHR.error)
> console.log(jqXHR.responseText);
> }
> });
>
>
>
> --- RESPONSE ---
> {
> "message" : "Expected a parameter named startNodeName",
> "exception" : "ParameterNotFoundException",
> "fullname" : "org.neo4j.cypher.ParameterNotFoundException",
> "stacktrace" : [
> "org.neo4j.cypher.internal.compiler.v2_1.pipes.QueryState$$anonfun$getParam$1.apply(QueryState.scala:45)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.pipes.QueryState$$anonfun$getParam$1.apply(QueryState.scala:45)",
> "scala.collection.MapLike$class.getOrElse(MapLike.scala:128)",
> "scala.collection.AbstractMap.getOrElse(Map.scala:58)",
> "org.neo4j.cypher.internal.compiler.v2_1.pipes.QueryState.getParam(QueryState.scala:45)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.commands.expressions.ParameterExpression.apply(ParameterExpression.scala:27)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.commands.Equals.isMatch(ComparablePredicate.scala:62)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.commands.Predicate.isTrue(Predicate.scala:34)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.pipes.FilterPipe$$anonfun$internalCreateResults$1.apply(FilterPipe.scala:32)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.pipes.FilterPipe$$anonfun$internalCreateResults$1.apply(FilterPipe.scala:32)",
> "scala.collection.Iterator$$anon$14.hasNext(Iterator.scala:390)",
> "scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)",
> "scala.collection.Iterator$$anon$14.hasNext(Iterator.scala:388)",
> "org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$hasNext$1.apply$mcZ$sp(ClosingIterator.scala:37)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:34)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:34)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$failIfThrows$1.apply(ClosingIterator.scala:93)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.decoratedCypherException(ClosingIterator.scala:102)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.failIfThrows(ClosingIterator.scala:91)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.hasNext(ClosingIterator.scala:34)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.PipeExecutionResult.hasNext(PipeExecutionResult.scala:167)",
> "scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)",
> "scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:29)",
>
> "org.neo4j.cypher.internal.compiler.v2_1.PipeExecutionResult$$anon$1.hasNext(PipeExecutionResult.scala:75)",
>
> "org.neo4j.helpers.collection.ExceptionHandlingIterable$1.hasNext(ExceptionHandlingIterable.java:44)",
>
> "org.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42)",
>
> "org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:62)",
> "org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)",
> "org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)",
>
> "org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:83)",
>
> "org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:41)",
> "org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:224)",
> "org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:156)",
> "org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:139)",
> "org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:71)",
> "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:122)",
> "java.lang.reflect.Method.invoke(Method.java:606)",
> "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)",
> "java.lang.Thread.run(Thread.java:744)" ]
>
> --- END RESPONSE ---
>
> So the good part is that it IS detecting that the parameter is not being
> substituted in the query. Feels like it is not detecting the variable and
> value in the JSON. But I have tried this like 30 different ways - same
> results - no success.
>
> And Adding a to the header of the AJAX request such as:
>
> contentType: "application/json;charset=utf-8",
>
> Results in a:
>
> No 'Access-Control-Allow-Origin' header is present on the requested resource.
>
> So I am pretty sure this is NOT a simple header problem - seems to be either
> a JSON structure / value problem - or a parsing problem in neo4j...
>
>
>
> ANY THOUGHTS?!?!?!
>
>
> Dave
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.