Reputation: 1565
I'm trying to load some pages in divs, each one in its time. Let me explain...
I have a table...
<table id="table4">
<tr>
<td>Id:</td>
<td>Nome:</td>
</tr>
<tr>
<td>1515</td>
<td>Thiago</td>
</tr>
<tr>
<td>2015</td>
<td>Guttierre</td>
</tr>
</table>
Each "id" represents a piece of a link. Like this...
I loaded this page (http://test.com/1515) into a DIV.
The point is... I have to change the first page loaded into the div(http://test.com/1515) for the next page(http://test.com/2015). According to the table.
How can I set a time to change the content of the DIV?
Thanks,
Thiago.
//////////////////////////////////////////////////////////////////////////////////
Guys, I wanna to do this....
Load a page into a DIV...
$("#dialog").load('www.test.com/' + 1515 + '.aspx');
After 90 seconds the DIV loads the other value...
$("#dialog").load('www.test.com/' + 2015 + '.aspx');
I can't do this, I dont know why. I did a test with...
$("#loadedPage").fadeOut(50000);
And it only faded out after the last loaded page. Help me!. Please!
Upvotes: 0
Views: 218
Reputation: 1565
For those who has the same problem. How I fixed it (by my way)...
e.preventDefault();
//Define as variáveis
var aux = 2;
var IdOsArray = new Array(); //
var idSOS = $("#table4 tr:nth-child(" + aux + ") td:nth-child(1)").text();
var i = 0;
//Verify on table
while ((idSOS != "") && (idSOS != undefined) && (idSOS != null) && (idSOS != "Número")) {
IdOsArray[i] = $("#table4 tr:nth-child(" + aux + ") td:nth-child(1)").text();
idSOS = IdOsArray[i];
i++; aux++;
};
i = 0;
function _(i) {
idSOS = IdOsArray[i];
$("#dialog,#closediv").css({ 'display': 'none' });
if ((idSOS != "") && (idSOS != undefined) && (idSOS != 'undefined') && (idSOS != null) && (idSOS != "Número")) {
_show(idSOS);
setTimeout(function() {
i++;
return _(i)
}, 10000);
} //end IF
else { _hide() };
};
_(i);
function _show(idSOS) {
var maskHeight = "99%";
var maskWidth = "99%";
$('#mask').css({ 'width': maskWidth, 'height': maskHeight });
//efeito de transição
$('#mask').fadeIn(800);
$("#dialog").fadeIn(1600);
$('#mask').fadeTo("slow", 1);
$('#dialog').fadeTo("slow", 1);
$("#dialog, #mask,#closediv").css({ 'display': 'block' });
//armazena a largura e a altura da janela
var winH = $(window).height();
var winW = $(window).width();
//centraliza na tela a janela popup
$("#dialog, #mask").css('top', '2px');
$("#dialog, #mask").css('left', '2px');
//Modal Content
$("#dialog").load('http://localhost/superdata/osview/osview.aspx?sos=' + idSOS);
}
function _hide() {
$('#mask,#closediv,.window').hide();
};
//close click
$('#mask,#closediv,.window').click(function GetOut(e) {
_hide();
});
});
Upvotes: 0
Reputation: 13351
If you want to set something on a timer, you can use JavaScript's setTimeout
or setInterval
methods:
setTimeout ( expression, timeout );
setInterval ( expression, interval );
Where expression
is a function and timeout
and interval
are integers in milliseconds. setTimeout
runs the timer once and runs the expression
once whereas setInterval will run the expression
every time the interval
passes.
So in your case it would work something like this:
setTimeout(function() {
//set the contents of the div
}, 5000); //5 seconds
Upvotes: 2