Jump to content
GIGN Forum

Js Refresh


Dj_Stay
 Share

Recommended Posts

Sveiki, es taisu webu un man gribās uzstaisīt, monitõram un statistkai to, lai nevaig taisīt refresh, lai JS automātiski refresho.. Varbūt nemāku izskaidrot, bet ir dažos webos tā.

Atradu kaut ko šādu.

<script>

$(document).ready(function() {

$("#responsecontainer").load("response.php");

var refreshId = setInterval(function() {

$("#responsecontainer").load('response.php?randval='+ Math.random());

}, 9000);

$.ajaxSetup({ cache: false });

});

</script>

Edited by Dj_Stay
Link to comment
Share on other sites

Skaidrs.. Es tāā dzīļi, dziļi pameklēju un atradu.

Ja kādam vaig ņemat. :)


<script type="text/javascript">

function ajaxFunction(){

var ajaxRequest;

try{

// Opera 8.0+, Firefox, Safari

ajaxRequest = new XMLHttpRequest();

} catch (e){

// Internet Explorer Browsers

try{

ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");

} catch (e) {

try{

ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");

} catch (e){

//browsers all not support, rare case

alert("Your browser broke!");

return false;

}

}

}

return ajaxRequest;

}

function showData() {

htmlRequest = ajaxFunction();

if (htmlRequest==null){ // If it cannot create a new Xmlhttp object.

alert ("Browser does not support HTTP Request");

return;

}

htmlRequest.onreadystatechange = function(){

if(htmlRequest.readyState == 4){

document.getElementById("shoutarea").innerHTML = htmlRequest.responseText;

}

}

htmlRequest.open("GET", "mon/pub.php", "inc/jaunforum.php", true);

htmlRequest.send(null);

}

showData();

setInterval("showData()",10000);

function saveData(){

htmlRequest = ajaxFunction();

if (htmlRequest==null){ // If it cannot create a new Xmlhttp object.

alert ("Browser does not support HTTP Request");

return;

}

if(document.shoutbox.shouter_comment.value == "" || document.shoutbox.shouter_comment.value == "NULL"){

alert('Monis zdohnul?! :D');

return;

}

htmlRequest.open('POST', 'mon/pub.php', 'inc/jaunforum.php');

htmlRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

htmlRequest.send('message='+document.shoutbox.shouter_comment.value);

document.shoutbox.shouter_comment.value = ''; // Updates the shout box’s text area to NULL.

document.shoutbox.shouter_comment.focus(); // Focuses the text area.

}

</script>

Lai palaistu raksti div


<div id="shoutarea">

To, ko vaig refresh

</div>

Link to comment
Share on other sites

Itkā

<script type="text/javascript" language="javascript" src="inc/js/jquery-1.3.2.min.js"></script>

Kr4 ir tāā, ka man refresh ir monim, bet Jaunākais forumā nav.

Izmantoju šito script.

<script type="text/javascript">

function Ajax(){

var xmlHttp;

try{

xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari

}

catch (e){

try{

xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer

}

catch (e){

try{

xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

}

catch (e){

alert("No AJAX!?");

return false;

}

}

}

xmlHttp.onreadystatechange=function(){

if(xmlHttp.readyState==4){

document.getElementById('shoutarea').innerHTML=xmlHttp.responseText;

setTimeout('Ajax()',10000);

}

}

xmlHttp.open("GET","mon/pub.php","inc/jaunforum.php",true);

xmlHttp.send(null);

}

window.onload=function(){

setTimeout('Ajax()',10000);

}

</script>

Link to comment
Share on other sites

no kada saita tu tos kodus dabuji? :axe:

google ari pastav..


<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>

<script>

$(document).ready(function(){

/* pirmais */

$("#huina").load('/kkas.html');

/* otrs */

$("#huina2").load('/kkas2.html');

});

/* pirmais */

var refreshId = setInterval(function()

{

$('#huina').load('/kkas.html');

}, 5000);

/* otrs */

var refreshId = setInterval(function()

{

$('#huina2').load('/kkas2.html');

}, 5000);

</script>

<div id="huina">

<div style="display:block;margin:0 auto" />ieladee1</div>

</div>

<div id="huina2">

<div style="display:block;margin:0 auto" />ieladee2</div>

</div>

Link to comment
Share on other sites

no kada saita tu tos kodus dabuji? :axe:

google ari pastav..


<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>

<script>

$(document).ready(function(){

/* pirmais */

$("#huina").load('/kkas.html');

/* otrs */

$("#huina2").load('/kkas2.html');

});

/* pirmais */

var refreshId = setInterval(function()

{

$('#huina').load('/kkas.html');

}, 5000);

/* otrs */

var refreshId = setInterval(function()

{

$('#huina2').load('/kkas2.html');

}, 5000);

</script>

<div id="huina">

<div style="display:block;margin:0 auto" />ieladee1</div>

</div>

<div id="huina2">

<div style="display:block;margin:0 auto" />ieladee2</div>

</div>

Paldies, strādā.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...