Saudações. Desenvolvo com PHP já faz um bom tempo, porém estou me adaptando ao Ajax, e ainda possuo algumas dúvidas. Pessoal estou tendo problemas que estão me abalando emocionalmente (rs). Estou desenvolvendo um site onde existem diversos banners e dados que devem ser atualizados a cada 5 seg. No Firefox tudo funciona maravilhosamente, mas quando se trata do Internet Explorer nem em todos os computadores funciona a atualização, somente alguns computadores. Testei em computadores com IE6 e IE7 e em ambos houve casos de funcionar ou de não funcionar. Abaixo estou colocando os códigos que estou usando e também publiquei para que possam ver se me dão um suporte e derrepente me dar uma idéia do que possa estar ocorrendo. Desde já agradeço as ajudas que possam surgir. O arquivo está publicado em: http://www.infotelclassificados.com.br/site/teste.html teste.js var req;
function loadXMLDoc(url)
{
req = null;
// Procura por um objeto nativo (Mozilla/Safari)
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// Procura por uma versão ActiveX (IE)
} else if (window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP"); //IE ActiveX versão mais nova
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP"); //IE ActiveX versão mais velha
} catch (E) {
req = false; // sem suporte
}
}
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}
function processReqChange()
{
// apenas quando o estado for "completado"
if (req.readyState == 4) {
// apenas se o servidor retornar "OK"
if (req.status == 200) {
// procura pela div e insere o conteudo
// retornado nela, como texto HTML
document.getElementById('anunciosinternos').innerHTML = req.responseText;
} else {
alert("Houve um problema ao obter os dados:\n" + req.statusText);
}
}
}
function buscarAnuncio()
{
loadXMLDoc("teste.php");
}
// Recarrega
window.setInterval("buscarAnuncio()", 5000);
teste.php
<?
include"conexao.php";
include"functions.php";
?>
<?
$bAnunciantes = mysql_query("SELECT id, idcidade, banner_logomarca, banner_anuncio, empresa,
descricao, endereco, bairro, telefone1, telefone2, telefone3, telefone4, telefone5 FROM tbl_anunciantes ORDER BY RAND() LIMIT 9");
$nAnunciantes = mysql_num_rows($bAnunciantes);
for($i=0;$i<$nAnunciantes;$i++){
$id = @mysql_result($bAnunciantes,$i,"id");
$empresa = @mysql_result($bAnunciantes,$i,"empresa");
$empresa = caracteres($empresa);
$telefone1 = @mysql_result($bAnunciantes,$i,"telefone1");
?><div style="margin:5px;"><?=$empresa?><br><?=$telefone1?></div><?
}
?>
teste.html
<html>
<head>
<title>Anuncios Internos</title>
<style type="text/css">
body{
margin:0px;
font-family:"Trebuchet MS", Arial;
font-size:13px;
}
body p{
margin:0px;
}
</style>
<script language="javascript" type="text/javascript" src="teste.js"> </script>
</head>
<body>
<div id="anunciosinternos"></div>
</body>
</html>