Blesta Addons Posted January 26, 2015 Report Posted January 26, 2015 Hello . Is thier any qick tip or methode to reload module tab content every x seconds with ajax request ? Any tip or help will save me some hours of searching and testing . Quote
serge Posted January 26, 2015 Report Posted January 26, 2015 Not exactly what you said, What I have done when I was using whmcs, was to create a button "refresh view" Blesta Addons 1 Quote
a.daniello Posted January 26, 2015 Report Posted January 26, 2015 var interval = 1000; // 1000 = 1 second, 3000 = 3 seconds function doAjax() { $.ajax({ type: 'POST', url: 'increment.php', data: $(this).serialize(), dataType: 'json', success: function (data) { doSomething();// first set the value }, complete: function (data) { // Schedule the next setTimeout(doAjax, interval); } }); } setTimeout(doAjax, interval); Quote
a.daniello Posted January 26, 2015 Report Posted January 26, 2015 I think that also Blesta has its method, but now i don't remember where it is Quote
a.daniello Posted January 26, 2015 Report Posted January 26, 2015 From Blesta code: function startUpdateTimer() { return setTimeout(function() { $(this).blestaRequest("GET", '<?php echo $this->Html->safe($this->base_uri . "plugin/support_manager/admin_tickets/index/" . $this->Html->ifSet($status, "open") . "/");?>', null, // Success response function(data) { if (data.replacer == null) { $("#admin_tickets").html(data.content); $("#admin_tickets").blestaBindToolTips(); } else { $(data.replacer, $("#admin_tickets")).html(data.content); $(data.replacer, $("#admin_tickets")).blestaBindToolTips(); } }, null, {dataType: 'json'} ); }, 30000); } function stopUpdateTimer(timer) { clearTimeout(timer); } Hope this help you Blesta Addons 1 Quote
Blesta Addons Posted January 26, 2015 Author Report Posted January 26, 2015 Not exactly what you said, What I have done when I was using whmcs, was to create a button "refresh view" i need a auto refrech . Quote
Blesta Addons Posted January 26, 2015 Author Report Posted January 26, 2015 var interval = 1000; // 1000 = 1 second, 3000 = 3 seconds function doAjax() { $.ajax({ type: 'POST', url: 'increment.php', data: $(this).serialize(), dataType: 'json', success: function (data) { doSomething();// first set the value }, complete: function (data) { // Schedule the next setTimeout(doAjax, interval); } }); } setTimeout(doAjax, interval); this code is sending a request to a file, and grab the returned data . the probleme here is replacing the tab with the new content . but i will look at it . Quote
Blesta Addons Posted January 26, 2015 Author Report Posted January 26, 2015 From Blesta code: function startUpdateTimer() { return setTimeout(function() { $(this).blestaRequest("GET", '<?php echo $this->Html->safe($this->base_uri . "plugin/support_manager/admin_tickets/index/" . $this->Html->ifSet($status, "open") . "/");?>', null, // Success response function(data) { if (data.replacer == null) { $("#admin_tickets").html(data.content); $("#admin_tickets").blestaBindToolTips(); } else { $(data.replacer, $("#admin_tickets")).html(data.content); $(data.replacer, $("#admin_tickets")).blestaBindToolTips(); } }, null, {dataType: 'json'} ); }, 30000); } function stopUpdateTimer(timer) { clearTimeout(timer); } Hope this help you i will try it , not sure if it feet my need . as what i need is simple but is complicated with tabs in module , maybe in plugin will work like a charm . Quote
a.daniello Posted January 26, 2015 Report Posted January 26, 2015 this code is sending a request to a file, and grab the returned data . the probleme here is replacing the tab with the new content . but i will look at it . Why not replace dosomething(); with $('#id_your_div').html(data); ? Quote
Blesta Addons Posted January 26, 2015 Author Report Posted January 26, 2015 Why not replace dosomething();with $('#id_your_div').html(data);? Ok to well explain my need , i want to change my tab module of reinstall a VM in proxmox , what i need exactly when i send a reinstall command to xx/x/tabsreinstall/install/ i want to affich a loading image this image will be shown until the install proccess is completed . how i can check the install is completed ? proxmox has a ticket request system , until the ticket request "xxxxxxxxxx" is in running mode so the install is not completed , when this ticket is stopped the install is completed . i have already implement a backgourd for this in activating new VM and is working like a charm . now i want to show the backround proccess . any one thanks a lot for this jquery code , i have got a idea now, i will try it this night . if success i will change the install code in my preoxmox module and releasing the first beta Quote
a.daniello Posted January 26, 2015 Report Posted January 26, 2015 If process takes few time, you can add the "loading image" and its container/overlay in the page and make these hidden (class="hidden"), then show it when ajax call success ( $('#id_of_loading_overlay').removeClass('hidden'); ) or completed (depend on your check code). In this case you don't use a JS timer but take control by server side (for example, using https://github.com/ZzAntares/ProxmoxVE). This is only an idea, i don't know your code so i wait "this night" to see it! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.