I want to create an event with YUI where every two seconds, refresh the page.
var companymain = {
init: function() {
companymain.form = document.getElementById('companymain');
//I need a event or something and repet this function.
YAHOO.util.Event.addListener(companymain.form, 'EVENTNEED', companymain.submit_func);},
submit_func: function(e) { //stuff refresh page}
ideas?
Regards.
What you seem to want to do isn’t really an event sort of thing. The following shows the general idea that you need to implement:
This declares a
repeatedRefresh()function and calls it after 2000ms. The function itself will do an Ajax call to update the page and then usesetTimeout()to queue up another call to itself after 2000ms. I’d suggest putting thesetTimeout()inside the Ajax completion/success callback so that subsequent calls happen 2000ms after the previous one completes.I’ve left the actual Ajax code out above because I’m not familiar with YUI (except in a very general way), but since you’ve tagged your question with jQuery this is one way to do it with jQuery:
Or if your server-side code is returning HTML you can simplify things by using the
.load()method to automatically load the returned HTML into a particular element (say a div):Finally, to try to use your existing
companymainstructure: