Am facut un apel la fisier cu ajax la fiecare 1 secunda, dar as vrea sa stiu daca imi creste traficul/cedare server.... alte solutie pentru a nu creste traficul doar sa-mi raspunda cererile prin ajax ... cum pot face ??
fisier 'index.php':
Cod: Selectaţi tot
<script src="jquery.min.js"></script>
<script src="jquery-ui.min.js"></script>
<script>
$(function() {
setInterval(function() {
$.ajax({
type: "GET",
url: "getData.php",
dataType: "json",
cache: false,
timeout: 50000,
success: function(data) {
var json = data.msg;
// html is a string of all output of the server script.
$("#element").html(json);
}
});
}, 1000);
});
</script>
<div id="element"></div>
..si fisierul 'getData.php':
Cod: Selectaţi tot
<?php
$response_doi = "Hello!";
$json = '{
"msg":"'.$response_doi.'"
}';
echo $json;
?>