Meus amigos,
Estou com esse código a baixo, no explorer e mozila funciona muito bem mais no chrome não funciona.
a função é chamada por um select
alguem aqui pode ajudar a encontrar uma solução?
function objetoAjax(){
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;
}
function List(id){
divCategorias = document.getElementById('categorias');
ajax=objetoAjax();
ajax.open("GET", "list.php?pag="+id);
divCategorias.innerHTML= '<img src="images/loading.gif">';
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divCategorias.innerHTML = ajax.responseText
}
}
ajax.send(null)
}
<select class="sty_select" id="cat" name="cat"/>
<option onClick="List('id=1');">id 1</option>
<option onClick="List('id=2');">id 2</option>
</select>
Função Não Chama No Chrome
Started By k9studio, 28/02/2012, 07:51
4 replies to this topic
#1
Posted 28/02/2012, 07:51
#2
Posted 28/02/2012, 08:15
Olá,
Fiz uns testes com a sua função, e aparentemente, está normal. Tanto no Firefox 9.0.1 quanto no Chrome 17.0.963, retornou um objeto XMLHttpRequest().
Mas eu alteraria isso:
try //Google Chrome
{
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET",file,false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML.documentElement;
}
Para isso:
try //Google Chrome
{
var xmlhttp = new window.XMLHttpRequest();
}
Achei no mínimo estranho dentro deste bloco você tentar fazer uma requisição, sendo que a função retorna o objeto, a requisição é feita fora.
E está usando uma variável que não vi no código, file.
Abraços.
Fiz uns testes com a sua função, e aparentemente, está normal. Tanto no Firefox 9.0.1 quanto no Chrome 17.0.963, retornou um objeto XMLHttpRequest().
Mas eu alteraria isso:
try //Google Chrome
{
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET",file,false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML.documentElement;
}
Para isso:
try //Google Chrome
{
var xmlhttp = new window.XMLHttpRequest();
}
Achei no mínimo estranho dentro deste bloco você tentar fazer uma requisição, sendo que a função retorna o objeto, a requisição é feita fora.
E está usando uma variável que não vi no código, file.
Abraços.
#3
Posted 28/02/2012, 09:07
Olá Feko,
fiz como indicou mais continua a mesma coisa, no chrome não funciona, versão do chrome 19.0.1054.0 canary
function objetoAjax(){
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();
}
catch(e)
{
xmlhttp = false;
}
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function List(id){
divCategorias = document.getElementById('categorias');
ajax=objetoAjax();
ajax.open("GET", "list.php?pag="+id);
divCategorias.innerHTML= '<img src="images/loading.gif">';
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divCategorias.innerHTML = ajax.responseText
}
}
ajax.send(null)
}
fiz como indicou mais continua a mesma coisa, no chrome não funciona, versão do chrome 19.0.1054.0 canary
function objetoAjax(){
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();
}
catch(e)
{
xmlhttp = false;
}
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function List(id){
divCategorias = document.getElementById('categorias');
ajax=objetoAjax();
ajax.open("GET", "list.php?pag="+id);
divCategorias.innerHTML= '<img src="images/loading.gif">';
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divCategorias.innerHTML = ajax.responseText
}
}
ajax.send(null)
}
#5
Posted 29/10/2017, 07:22
Buy Isotretinoin Cephalexin Useage Viagra Ohne Rezept Apotheke Kaufen levitra lowest price Estrogen Without A Prescription Female Viagra For Sale When Does An Amoxicillin Capsule Expire
Finasteride Cod Accepted Website Tretinoin Without Prescription Propecia Substitutes mail order levitra 90 day supply Vidal Tamoxifene Amoxil Reaction Allergique
Finasteride Cod Accepted Website Tretinoin Without Prescription Propecia Substitutes mail order levitra 90 day supply Vidal Tamoxifene Amoxil Reaction Allergique
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)