hola ahora neceto su ayuda aqui esta un codigo que revise y probe y reacciona perfctamente pero solo fncia con un archov de texteo y quiero que reaccione con uno de php aqui estanm los codigo:
Código Javascript
:
Ver original<script type="text/javascript">
var Comet = Class.create();
Comet.prototype = {
timestamp: 0,
url: 'backend.php',
noerror: true,
initialize: function() { },
connect: function()
{
this.ajax = new Ajax.Request(this.url, {
method: 'get',
parameters: { 'timestamp' : this.timestamp },
onSuccess: function(transport) {
// handle the server response
var response = transport.responseText.evalJSON();
this.comet.timestamp = response['timestamp'];
this.comet.handleResponse(response);
this.comet.noerror = true;
},
onComplete: function(transport) {
// send a new ajax request when this request is finished
if (!this.comet.noerror)
// if a connection problem occurs, try to reconnect each 5 seconds
setTimeout(function(){ comet.connect() }, 5000);
else
this.comet.connect();
this.comet.noerror = false;
}
});
this.ajax.comet = this;
},
disconnect: function()
{
},
handleResponse: function(response)
{
$('content').innerHTML += '<div>' + response['msg'] + '</div>';
},
doRequest: function(request)
{
new Ajax.Request(this.url, {
method: 'get',
parameters: { 'msg' : request }
});
}
}
var comet = new Comet();
comet.connect();
</script>
aqui esta el php llamada backend.php
Código PHP:
Ver original<?php
$filename = dirname(__FILE__).'/data.txt';
// store new message in the file
$msg = isset($_GET['msg']) ?
$_GET['msg'] : ''; if ($msg != '')
{
}
// infinite loop until the data file is not modified
$lastmodif = isset($_GET['timestamp']) ?
$_GET['timestamp'] : 0; while ($currentmodif <= $lastmodif) // check if the data file has been modified
{
usleep(10000); // sleep 10ms to unload the CPU }
// return a json array
$response['timestamp'] = $currentmodif;
?>
ahora no se y e intentado pero no da resultado por favor ayudenme!!