Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/05/2011, 15:28
crscrew
 
Fecha de Ingreso: mayo-2011
Ubicación: san carlos
Mensajes: 7
Antigüedad: 12 años, 11 meses
Puntos: 1
ajax y jquery no me funcionan :(

Hola amigos resulta que estoy haciendo una pagina tipo red social para un proyecto en la U y resulta que la tengo casi ok salvo por un detalle..... estoy utilizando jquery para los efectos y ya terminando implemente un troso de código AJAX y para sorpresa mia jquery dejo de funcionar pero si funciona ajax (el ajax que utilizo es para actualizar un div sin recargar la web completa) el ajax funciona correctamente pero jquery como que se bloquea por asi decirlo. Revizando el codigo de mi archivo ajax di con unas lineas que son las que provocan el error.

troso de codigo de ajax.js que provoca el error

// The XMLHttpRequest object
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') {
xmlhttp = new XMLHttpRequest();
}

pues bien a continuacion les presento el codigo completo de ajax.js

Código:
var seconds = 5; // el tiempo en que se refresca
var divid = "container"; // el div que quieres actualizar!
var url = "index.php"; // el archivo que ira en el div
////////////////////////////////
//
// Refreshing the DIV
//
////////////////////////////////
function refreshdiv(){
// The XMLHttpRequest object
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') {
xmlhttp = new XMLHttpRequest();
}
// Timestamp for preventing IE caching the GET request
var fetch_unix_timestamp ="";// lets declare the variable
fetch_unix_timestamp = function()
{
return parseInt(new Date().getTime().toString().substring(0, 10))
}
var timestamp = fetch_unix_timestamp();
var nocacheurl = url+"?t="+timestamp;
// The code...
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
document.getElementById(divid).innerHTML=xmlhttp.responseText;
setTimeout('refreshdiv()',seconds*1000);
}
}
xmlhttp.open("GET",nocacheurl,true);
xmlhttp.send(null);
}
// Empieza la función de refrescar
window.onload = function startrefresh(){
setTimeout('refreshdiv()',seconds*1000);
}
la versión de jquery es: jQuery JavaScript Library v1.3.2

en el index los llamo así:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>

<script src="actualiza.js" type="text/javascript"></script>
<script type="text/javascript" src="jquery.js"></script>

así comienza todo :)


amigos agradezco su ayuda y pido disculpas si es que me equivoco de foro y me queda mal diseñado es que es primera vez que realizo algo asi :)


pd: lo que necesito es que funcionen ambos js (jquery y ajax) sin que se bloquee alguno (quizas tengo las llamadas de forma erronea)