Jump to content


Photo

Função Não Chama No Chrome


  • Faça o login para participar
4 replies to this topic

#1 k9studio

k9studio

    k9studio

  • Usuários
  • 291 posts
  • Sexo:Masculino
  • Interesses:php, mysql, asp

Posted 28/02/2012, 07:51

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>

#2 Feko

Feko

    Normal

  • Usuários
  • 87 posts
  • Sexo:Não informado
  • Localidade:Balneário Camboriú - SC

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.

#3 k9studio

k9studio

    k9studio

  • Usuários
  • 291 posts
  • Sexo:Masculino
  • Interesses:php, mysql, asp

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)
}

#4 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 14/10/2017, 00:27

Cialis Benefici cialis Amoxicillen Buy Online
Donde Venden Viagra Madrid viagra Cialis Online Rezeptfrei Kaufen

#5 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

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




0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq