كود PHP:
<script type="text/javascript">
<!--
// [url]www.wino.ws[/url] & [email]script@wino.ws[/email]
//_________________________
var $id = "data_include";
var $time = 5 // 1 = 1 second
var $img_loading = '<img src="http://www.napyfab.com/ajax-indicators/images/progressbar_microsoft.gif">';
var $msg = '<br>loading ....';
//_________________________
var http_request = false;
include = function($url,$method,$send){
if(!$url)return false;
if(!$method)$method = "GET";
if(!$send)$send = null;
document.getElementById($id).innerHTML = $img_loading+$msg; // dellet
http_request = false;
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP');
document.getElementById($id).innerHTML = "";
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open($method, $url, true);
http_request.setRequestHeader('Content-Type', 'text/html; charset:windows-1256');
http_request.send($send);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
document.getElementById($id).innerHTML = http_request.responseText;
} else {
alert('There was a problem with the request.');
document.getElementById($id).innerHTML = "";
return false
}
}
}
window.setInterval(function(){include('http://www.swalif.net/softs')},1000*$time);
//-->
</script>
<!-- ////////////////// -->
<div align="center" id="data_include"></div>
يمكنك إزالة هذا السطر ان اردت ان لا تظهر صورة التحميل
كود PHP:
document.getElementById($id).innerHTML = $img_loading+$msg; // dellet
كما يمكنك التعديا على الكود الذي أعطيتك قبلا بتغيير هذه الدالة
كود PHP:
window.setTimeout(function(){
document.getElementById('data_include').innerHTML = include('http://localhost/phpz/data.php')
},1000*time);
الى
كود PHP:
window.setInterval(function(){
document.getElementById('data_include').innerHTML = include('http://localhost/phpz/data.php')
},1000*time);