Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Carlos Ventura

Script não funciona no I.E.

Recommended Posts

E ai pessoal,

estou com um problema aqui e queria saber se vcs conseguem me ajudar!

estou com um script aqui em AJAX e PHP e fica atualizando a cada 1 segundo 2 div´s, até q funcionou no Firefox, Chrome e Netscape , so que no I.E. não! aqui vai o site q eu to fazendo... ta em desenvolvimento, na verdade em teste destes script, http://www.vocenolance.com.br/site/leilao

 

e aqui vai o script em PHP q gera o AJAX para cada DIV!, é meio grandinho!!

<?php require("../conexao_bd.php");?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $tit_site;?></title>
<link rel="stylesheet" href="../css/site.css" type="text/css" media="screen" />
<script>
<?php 
$sqlProd3 = mysql_query("Select id from produtos where ativo='Sim' and finalizado != 'Sim' order by id DESC");
while($r3=mysql_fetch_array($sqlProd3)){ 
?>
AjaxV<?php echo $r3[0]?> = function (){   
    try{   
        xmlhttpV<?php echo $r3[0]?>  = new XMLHttpRequest();
    }catch(ee){   
        try{   
            xmlhttpV<?php echo $r3[0]?>  = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){   
            try{   
                xmlhttpV<?php echo $r3[0]?>  = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(E){   
                xmlhttpV<?php echo $r3[0]?>  = false;   
            }   
        }   
    }   

}
AjaxU<?php echo $r3[0]?> = function (){   
    try{   
        xmlhttpU<?php echo $r3[0]?>  = new XMLHttpRequest();
    }catch(ee){   
        try{   
            xmlhttpU<?php echo $r3[0]?>  = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){   
            try{   
                xmlhttpU<?php echo $r3[0]?>  = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(E){   
                xmlhttpU<?php echo $r3[0]?>  = false;   
            }   
        }   
    }   

}

function ajaxUser<?php echo $r3[0]?>( nomeUrl<?php echo $r3[0]?>, divRetorno<?php echo $r3[0]?> ){   
var divInsereResposta<?php echo $r3[0]?> = document.getElementById( divRetorno<?php echo $r3[0]?> );
  	
	url<?php echo $r3[0]?> = antiCacheRandU(nomeUrl<?php echo $r3[0]?>);
	AjaxU<?php echo $r3[0]?>(); 
	
	xmlhttpU<?php echo $r3[0]?>.open("GET", url<?php echo $r3[0]?>, true);
	xmlhttpU<?php echo $r3[0]?>.onreadystatechange=function() {
	    if (xmlhttpU<?php echo $r3[0]?>.readyState==4){
			
                divInsereResposta<?php echo $r3[0]?>.innerHTML = xmlhttpU<?php echo $r3[0]?>.responseText;

	    }
	}
	 xmlhttpU<?php echo $r3[0]?>.send(null)
   
} 
function ajaxValor<?php echo $r3[0]?>( nomeUrl<?php echo $r3[0]?>, divRetorno<?php echo $r3[0]?> ){   
var divInsereResposta<?php echo $r3[0]?> = document.getElementById( divRetorno<?php echo $r3[0]?> );
  	
	url<?php echo $r3[0]?> = antiCacheRandV(nomeUrl<?php echo $r3[0]?>);
	AjaxV<?php echo $r3[0]?>(); 
	
	xmlhttpV<?php echo $r3[0]?>.open("GET", url<?php echo $r3[0]?>, true);
	xmlhttpV<?php echo $r3[0]?>.onreadystatechange=function() {
	    if (xmlhttpV<?php echo $r3[0]?>.readyState==4){
			
                divInsereResposta<?php echo $r3[0]?>.innerHTML = xmlhttpV<?php echo $r3[0]?>.responseText;

	    }
	}
	 xmlhttpV<?php echo $r3[0]?>.send(null)
   
}
<?php } ?>
function antiCacheRandV(aurl){
        var dt = new Date();
        if(aurl.indexOf("?")>=0){// já tem parametros ADAPTA RANDOM / SE NAO CRIA PARAM. RANDOM
            return aurl + "&" + encodeURI(Math.random() + "_" + dt.getTime());
        }else{ return aurl + "?" + encodeURI(Math.random() + "_" + dt.getTime());}
}
function antiCacheRandU(aurl){
        var dt = new Date();
        if(aurl.indexOf("?")>=0){// já tem parametros ADAPTA RANDOM / SE NAO CRIA PARAM. RANDOM
            return aurl + "&" + encodeURI(Math.random() + "_" + dt.getTime());
        }else{ return aurl + "?" + encodeURI(Math.random() + "_" + dt.getTime());}
}
function atualiza(){
<?php 
$sqlProd2 = mysql_query("Select id from produtos where ativo='Sim' and finalizado != 'Sim' order by id DESC");
while($r=mysql_fetch_array($sqlProd2)){ 
?>
ajaxUser<?php echo $r[0]?>('user.php?id=<?php echo $r[0]?>','user<?php echo $r[0]?>');
ajaxValor<?php echo $r[0]?>('valor.php?id=<?php echo $r[0]?>','valor<?php echo $r[0]?>');
<?php } ?>
}

</script>
</head>
<body onload="atualiza()">
<table width="575" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" valign="top"><br />
        <br /></td>
  </tr>
  <tr>
    <td width="527" valign="top"><table width="514" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="514"><img src="../imagens/meioPrincipal/tit_produtosLeilao.jpg" width="514" height="40" /></td>
      </tr>
      <tr>
        <td background="../imagens/meioPrincipal/fundo_meio.jpg"><?php 
				$sqlProd = mysql_query("Select * from produtos where ativo='Sim' and finalizado != 'Sim' order by id DESC Limit 1");
				while($row_prod=mysql_fetch_array($sqlProd)){?>
              <div id="boxmeio">
                <table width="306" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="306" align="center"><table width="301" border="0" cellspacing="2" cellpadding="2">
                        <tr>
                          <td><div align="left"></div></td>
                        </tr>
                        <tr>
                          <td class="style7"><div align="left" class="style10"></div></td>
                        </tr>
                        <tr>
                          <td class="style8"><div align="left"></div></td>
                        </tr>
                        <tr>
                          <td class="style8"><div align="left" id="valor<?php echo $row_prod['id']?>"></div></td>
                        </tr>
                        <tr>
                          <td class="style8"><div align="left" id="user<?php echo $row_prod['id']?>"></div></td>
                        </tr>
                        <tr>
                          <td><div align="left"><a href="javascript:void(0);"><img src="../imagens/meioPrincipal/bt_darLance.jpg" width="111" height="22" border="0" /></a></div></td>
                        </tr>
                    </table></td>
                  </tr>
                </table>
              </div>
          <img src="../imagens/spacer.gif" width="1" height="3" />
              <?php } ?>
        </td>
      </tr>
      <tr>
        <td><img src="../imagens/meioPrincipal/baixo.jpg" width="514" height="9" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<script>
setInterval("atualiza()",1000); 
</script>

desde já agradeço!

 

Carlos Ventura

Compartilhar este post


Link para o post
Compartilhar em outros sites

O problema não é o PHP, é no Ajax. Vou mover para o fórum correto.

 

Tópico Movido

PHP http://forum.imasters.com.br/public/style_emoticons/default/seta.gif Ajax

Compartilhar este post


Link para o post
Compartilhar em outros sites

function ajaxUser<?php echo $r3[0]?>( nomeUrl<?php echo $r3[0]?>, divRetorno<?php echo $r3[0]?> ){   
[b]var divInsereResposta<?php echo $r3[0]?> = document.getElementById( divRetorno<?php echo $r3[0]?> );[/b]

       url<?php echo $r3[0]?> = antiCacheRandU(nomeUrl<?php echo $r3[0]?>);
       AjaxU<?php echo $r3[0]?>(); 

       xmlhttpU<?php echo $r3[0]?>.open("GET", url<?php echo $r3[0]?>, true);
       xmlhttpU<?php echo $r3[0]?>.onreadystatechange=function() {
           if (xmlhttpU<?php echo $r3[0]?>.readyState==4){

               divInsereResposta<?php echo $r3[0]?>.innerHTML = xmlhttpU<?php echo $r3[0]?>.responseText;

           }
       }
        xmlhttpU<?php echo $r3[0]?>.send(null)

} 

 

Voce está se referindo a um objeto que nao existe... nao achei a divRetornoX no seu codigo. Pelo menos e esse erro que o IE apresenta.

 

[]s

 

FM

Compartilhar este post


Link para o post
Compartilhar em outros sites

Verifica ai, esses foram os erros retornados pelo plugin do firefox FIREBUG, eh bom para ver se tuas funcoes estão rodando ok.

 

 

Erros que achou no firebug:

 

divInsereResposta6 is null
[Break on this error] Failed to load source for: http://vocenolance.com.br/site/leilao/leilao (linha 252)
divInsereResposta6 is null
[Break on this error] Failed to load source for: http://vocenolance.com.br/site/leilao/leilao (linha 269)

DEshow is not defined
[Break on this error] Failed to load source for: http://forum....ection=post&do=reply_post&f=143&t=357842index.ph...&t=357842 (linha 3588)
divInsereResposta8 is null
[Break on this error] Failed to load source for: http://vocenolance.com.br/site/leilao/leilao (linha 118)
divInsereResposta8 is null
[Break on this error] Failed to load source for: http://vocenolance.com.br/site/leilao/leilao (linha 135)

	

divInsereResposta7 is null
[Break on this error] Failed to load source for: http://vocenolance.com.br/site/leilao/leilao (linha 185)
divInsereResposta7 is null
[Break on this error] Failed to load source for: http://vocenolance.com.br/site/leilao/leilao (linha 202)

Compartilhar este post


Link para o post
Compartilhar em outros sites

Agora eu mudei... tava fazendo errado... e agora adicionei mais 2 produtos... e o ultimo produtos não aparece os dados igual aos de cima! nem no firefox q tava funfando normal ta mais... :( ... ta feio o negocio!!

eu poderia usar um script so de Ajax mais ai ele replica pra todos os outros produtos... deve ser cache do Ajax!

será q tem algum outro jeito mais enficaz de fazer isso q eu quero ?? pq eu tenho q fica atualizando essas div em 1 a 1 segundo!... nossa o servidor vai ficar louco!! rsrsrs

 

Obrigado por enquanto!

 

Carlos Ventura!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.