該servlet查詢數據庫並將數據引入到文件中。 此數據文件必須每10秒刷新一次,供用戶查看更新的信息。使用js函數觸發Servlet
我需要用javascript函數觸發servlet的幫助。我成功地在JS中獲得timeinterval方法,但我有調用servlet的問題。
var int=self.setInterval("trigger()",10000);
function(){
//Servlet queries the db and loads the data into the file.
trigger servlet ...???
" TriggerServlet? ......
}
你必須做出一個Ajax調用。如果你想使用jQuery,你可以檢查http://api.jquery.com/jQuery.ajax/ – 2012-02-04 09:33:22
你可以在這裏查看一個例子 - http://stackoverflow.com/questions/1830533/how-to-call-a -servlet-from-a-jquerys-ajax-function – 2012-02-04 09:50:58
如何從servlet中獲取響應值? – user1189150 2012-02-07 15:02:46