The moose likes HTML, CSS and JavaScript and the fly likes Trigger servlet with javascript function Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Trigger servlet with javascript function" Watch "Trigger servlet with javascript function" New topic
Author

Trigger servlet with javascript function

Mallu Kumar
Greenhorn

Joined: Feb 04, 2012
Posts: 1

I need help with triggering servlet with javascript function. I am successful in getting the timeinterval method in JS but I am having issue calling the servlet. The servlet queries the database and throws data in to a file.

This file has to be refreshed every 10 seconds for users to view the updated information.

var int=self.setInterval("trigger()",10000);

function(){

//Servlet queries the db and loads the data into the file.
trigger servlet ...???

" TriggerServlet? ......

}
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2329
A JavaScript library like Prototype makes this real simple with its Ajax.Request, Ajax.Updater and Ajax.PeriodicalUpdater objects: http://www.prototypejs.org/learn/introduction-to-ajax
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

Prototype is a dinosaur -- if a JavaScript library is going to be used, I'd recommend a more modern libraries such as jQuery, Dojo or YUI.

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
 
subject: Trigger servlet with javascript function
 
Threads others viewed
how to get the javascript data after it is loaded on a page
Possible reasons?
modifing data when Trigger fires
JSP and JavaScript
Right click and savetarget with javascript.
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture