Ver Mensaje Individual
  #6 (permalink)  
Antiguo 11/04/2014, 15:26
keko32
 
Fecha de Ingreso: marzo-2012
Mensajes: 25
Antigüedad: 12 años, 1 mes
Puntos: 1
Respuesta: Ajax php y mysql

OOOOUUUYEAAAA.
Pues que no consigo encontrar la solución, e buscado y buscado pero nada que lo consigo.
por el método que te comente me quede muy cerca de las necesidades. Pero nasti de plasti, seguiré indagando pues me parece que lo que mas se acerca lo que necesito es el metodo ajax como te comente, y si lo que me comentas incrementa la carga del servidor, pruuffffffffffff mal asunto.
mira esto que te dejo se podria adaptar si consiguiera que se recargara cada x tiempo, que por separado lo hace pero no lo consigo junto

Parte que recibe por GET


<html>
<head>
<script>
function showHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlht tp.responseText;
}
}
xmlhttp.open("GET","gethint.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>

<p><b>Start typing a name in the input field below:</b></p>
<form>
First name: <input type="text" onkeyup="showHint(this.value)">
</form>
<p>Suggestions: <span id="txtHint"></span></p>

</body>
</html>



y aki la parte que se actualiza cada x.
var seconds = 2; // el tiempo en que se refresca
var divid = "contenido"; // el div que quieres actualizar!
var url = "tiempo.php"; // el archivo que ira en el div

function refreshdiv(){

// The XMLHttpRequest object

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("Tu explorador no soporta AJAX.");
return false;
}
}
}

// Timestamp for preventing IE caching the GET request
var timestamp = parseInt(new Date().getTime().toString().substring(0, 10));
var nocacheurl = url+"?t="+timestamp;

// The code...

xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState== 4 && xmlHttp.readyState != null){
document.getElementById(divid).innerHTML=xmlHttp.r esponseText;
setTimeout('refreshdiv()',seconds*1000);
}
}
xmlHttp.open("GET",nocacheurl,true);
xmlHttp.send(null);
}

// Empieza la función de refrescar

window.onload = function(){
refreshdiv(); // corremos inmediatamente la funcion
}


El problema me surje que no se mezclarlos, vamos ni tampoco si se puede.