Jump to content

Recommended Posts

Posted


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);

Posted

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

Posted
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 .

Posted

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 .

Posted

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);

?

Posted

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 :)

Posted

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!

 

;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...