Ajax div yenilemek ( Ajax to refresh div )

by admin,

içindeki veriyi sürekli yeniletmek için aşağidaki kod işinizi görecektir. Bütün tarayıcılarda sorunsuz çalışmaktadır.

To the data in the continuously following code to see your work. Works smoothly in all browsers.

<html>
<head>
<script type=”text/JavaScript” language=”JavaScript”>
var xmlHttp=false;
try {
xmlHttp = new ActiveXObject(”Msxml2.xmlHttp”);
} catch (e) {
try {
xmlHttp = new ActiveXObject(”Microsoft.xmlHttp”);
}
catch (E) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest!=’undefined’) {
try {
xmlHttp = new XMLHttpRequest();
}
catch (e) {
xmlHttp=false;
}
}
if (!xmlHttp && window.createRequest) {
try {
xmlHttp = window.createRequest();
}
catch (e) {
xmlHttp=false;
}
}
function callServer(){
//burada çağiracağin sayfayı yazarsın
var url = “xml.asp” + “?tarih=” + new Date().getTime();

xmlHttp.open(”GET”, url, true);
xmlHttp.onreadystatechange = updatePage;{
if (xmlHttp.readyState==4) {
alert(xmlHttp.responseText)
}
}
xmlHttp.send(null)
}
function updatePage(){
//4 sorun yoksa demek
if(xmlHttp.readyState == 4){
//gelen cevap
var response = xmlHttp.responseText;
//hangi  gelcekse buraya yazılcak
okn.innerHTML = response;
//500 milisaniyede bir fonksiyonu cağirir
setTimeout(’callServer()’,500);
}
}
callServer(’url’);
</script>
</head>
< id=”okn”></><!– İçine bilginin geleceği  burasi, id sinin fonksiyondaki id ile aynı olmasına dikkat etmen gerekiyor –>

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

You must be logged in to post a comment.

Oyun Domain Registration Australia
Add to Technorati Favorites Technorati