2015-07-10 27 views
0

我在遊戲框架1.3.x的控制器中,我已經定義如下:GET方法播放

public static void plots(Long id) { 
    //... (Code goes here) 
    render(list); //Data to render 
} 

然後在一個單獨的HTML文件中的文件夾視圖我想「顯示」的結果從另一個html文件。我試圖通過以下方式來實現:

<script type="text/javascript"> 
    setInterval(function() { 
    $.get("plots", id, function(${list}){ //I want to give the list needed by the file plots.html 
     $("#result").html(list); //And then in "result" show the plots obtained 
     }) 
    }, 1000); 
    </script> 
... 
<span id="result"></span> 

但它根本不顯示任何內容。這個繪圖文件只需要這個列表,然後對數據做一個繪圖,但我很確定我不是以正確的方式編寫代碼,我的意思是,我沒有給這個函數提供正確的語法或參數。有任何想法嗎?謝謝!

PS:我的路線文件

# Routes 
# This file defines all application routes (Higher priority routes first) 
# ~~~~ 

# Home page 
GET /          Application.index 



# Ignore favicon requests 
GET  /favicon.ico       404 

# Map static resources from the /app/public folder to the /public path 
GET  /public/        staticDir:public 

# Catch all 
*  /{controller}/{action}     {controller}.{action} 
+0

確保您已在HTML頭標記 –

+1

包括jQuery的我覺得你的問題是,URL是無效的jQuery。 '「圖」對他來說是未知的,而不是有效的URL。我認爲您需要查看反向路由https://www.playframework.com/documentation/1.3.x/routes#reverse – tilois

+0

顯示您的路線 –

回答

0

您需要定義路線

GET  /plots          Application.plots(id:Long) 

$.get("/plots", id, function(${list}) 

或根據您的代碼

*  /{controller}/{action}     {controller}.{action} 

使用

$.get("Application/plots", id, function(${list}){ //Application is your controller name 

,但我會建議使用第一個

+0

我得到以下錯誤: 語法錯誤:缺少變量名 \t ...得到( 「/圖」,ID功能([樣品[3982]示例[3983]示例[3984],薩。 .. –