我是一個嘗試在Grails上尋找Neo4J的用戶的新手。如何發送Javascript變量到Grails控制器來查詢Neo4J
基本上,我通過Neo4J瀏覽器製作了20個食品雜貨店節點,我想創建一個簡單的Grails網站,讓用戶搜索食品雜貨並直觀地顯示與其相關的商品。
我index.gsp中有:
<input id="item" />
我viz.js有:
$('#item').keyup(function() {
var item = $('#item').val();
我的項目域類已經
class Item {
static mapWith = "neo4j"
String name
我ItemController類有:
def index() {
def item = Item.list() [item:item] //No idea, just trying out whatever i find :(
並且用類似的查詢:
def query = Item.cypherStatic ("""start n=node({Item}) match (n)-[r]->(x) where r='partner' return n, x)
問題:
- 我怎樣才能正確地發送JS '項目' 可變進ItemController?
- 如何使用'item'變量來正確查詢與該項目有'夥伴'關係的節點名稱?
隱藏字段是訪問變量的要求嗎?我發現了一個不需要隱藏字段的類似問題:http://stackoverflow.com/questions/7020519/how-to-get-the-input-from-a-text-box-on-a-webpage-form –
是的,隱藏字段是必需的:在您的代碼中,您不直接將值分配給文本字段。 – Motilal