I don’t have much experience in web programming, so I’ll try to simply explain the problem.
Here is my main method of a class that is run by CherryPy (cherrypy.quickstart(SLA_App())):
class SLA_app(Object):
def index(self):
global files;
files=[...]
createTable.createTable(files, '20/06/2012', '03/07/2012')
cherrypy.tree.mount(SLA_App(), '/',
config = { '/': { 'tools.staticdir.on' :True,
'tools.staticdir.dir' : 'some/dir',
'tools.staticdir.index' : 'cherry.html' }
})
return open('cherry.html')
index.exposed = True
I created a CherryPy server.
Each time when main page loads, a method needs to be executed. That method generates HTML code in some file. It is done in createTable.createTable(files). Say, it creates insert.html . The main page that is loading has jquery method that loads the code of the file to some and finally one gets the resulting page with everything.
Now, each time when someone enters a page I want that method to be executed. Problem is that it works only at server starting point. Every time when people enter the page, it will load the old file (method won’t be invoked). How to make it work every time when page is loading?
Finally I solved the problem. The thing is that every time web starts it should send the request to server, receive the answer and build the page dynamically. This can be accomplished with Ajax. Since I use jQuery, $.post method was quit useful in dealing.
To all that are new to this, just like me I advise to read “JavaScript and jQuery: The Missing Manual” by David Sawyer McFarland. Good Luck!