Derme Posted June 5, 2012 Report Share Posted June 5, 2012 Olá, uso um script ajax para incluir o conteúdo de um arquivo html em uma div.Funciona normalmente no IE e Fire Fox, mas não teve jeito de funcionar no Chrome.arquivo ajax.jsfunction GetXMLHttp() { var xmlhttp=false; try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ try //Google Chrome { var xmlhttp = new window.XMLHttpRequest(); xmlhttp.open("GET",file,false); xmlhttp.send(null); xmlDoc = xmlhttp.responseXML.documentElement; } catch(e) { xmlhttp = false; } } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } var xmlRequest = GetXMLHttp(); function mostra_conetudo(valor){ var url = valor; xmlRequest.onreadystatechange = mudancaEstado; xmlRequest.open("GET",url,true); xmlRequest.send(null); if (xmlRequest.readyState == 1) { document.getElementById("inclui_conteudo").innerHTML = "carregando..."; } return url; } function mudancaEstado(){ if (xmlRequest.readyState == 4){ document.getElementById("inclui_conteudo").innerHTML = xmlRequest.responseText; } } Pagina index.html <html> <head> <title>Untitled</title> <script language="javascript" src="ajax.js"></script> </head> <body> <a href="#" onclick="mostra_conetudo('conteudo.html')" class="lmenu">Que somos</a> <div id="inclui_conteudo" class="conetudo"></div> </body> </html> Página de conteúdo a ser incluído conteudo.html <p> Apenas um teste </p>Alguém sabe como resolver? Quote Link to comment Share on other sites More sharing options...
0 Willian Gustavo Veiga Posted June 5, 2012 Report Share Posted June 5, 2012 Existem erros no console do Chrome?Um abraço. Quote Link to comment Share on other sites More sharing options...
0 Derme Posted June 6, 2012 Author Report Share Posted June 6, 2012 Existem erros no console do Chrome?Um abraço.Sabe o que eu descobri!Online funciona, mesmo em servidor local, mas se abrir o arquivo diretamente aí não funciona não!! Quote Link to comment Share on other sites More sharing options...
Question
Derme
Olá, uso um script ajax para incluir o conteúdo de um arquivo html em uma div.
Funciona normalmente no IE e Fire Fox, mas não teve jeito de funcionar no Chrome.
arquivo ajax.js
Pagina index.html Página de conteúdo a ser incluído conteudo.htmlAlguém sabe como resolver?
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.