Ir para conteúdo

POWERED BY:

Arquivado

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

elfarelo

um clique, usar o ajax em duas ou mais divs

Recommended Posts

Olá galera do imasters.....Esse é o meu primeiro post feito aqui...... espero ajudar muito, pois em php entendo bem?mas eu estou com uma duvida com o ajax.Esse é o meu script que fiz para usar o ajax.... funciona perfeitamente....

   	 function mk(div, url) {				debug = 0;		ajax = false;						if(debug){ alert("debug:\n\nURL: " + url + "\nDESTINO: " + div); }		        if (window.XMLHttpRequest) { // Mozilla, Safari,...            ajax = new XMLHttpRequest();           if (ajax.overrideMimeType){                ajax.overrideMimeType('text/xml');            }        } else if (window.ActiveXObject) { // IE            try {                ajax = new ActiveXObject("Msxml2.XMLHTTP");            } catch (e) {                try {                   ajax = new ActiveXObject("Microsoft.XMLHTTP");                } catch (e) {}            }        }        if (!ajax) {            alert('Giving up :( Cannot create an XMLHTTP instance');            return false;        }		        ajax.onreadystatechange = function () {	        if (ajax.readyState == 4) {      			if (ajax.status == 200) {                	//Lê o texto            		texto = ajax.responseText;										//Desfaz o urlencode            		texto = texto.replace(/\+/g," ");		            texto = unescape(texto);        		    //Exibe o texto na div conteúdo selecionada                    document.getElementById(div).innerHTML = texto;          				} else {            		    alert('Desculpe, mas ouve um erro ao tentar abrir esse arquivo!');           	 	}//if       	 	}//if		 }//function				//SHOW CARREGANDO...		document.getElementById(div).innerHTML = '<img src="ajax_load.gif" width="32" height="32" />';		                ajax.open('POST', url, true);		ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");    	        ajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");    	        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");	   	ajax.setRequestHeader("Pragma", "no-cache");        ajax.send(null);				    }

Sempre que eu precisar buscar algo com o ajax eu coloco

evento="mk('ID_DA_DIV','URL')";exemplo:onclick="mk('resultBusca', 'buscarClientes.php?nome=elfarelo&idade=22')";

como eu disse antes funciona perfeitamente....mas eu to querendo fazer algo diferente.....eu criei esta função em js

function teste500(){	mk('infoClientes', 'infoClientes.php');	mk('editarCliente', 'editarCliente.php');	mk('relacionamentos', 'relacionamentos.php');	}

ou seja, quero que quando clicar em um link ou em um botão o ajax retorne em cada div.....mas não ta dando certo....alguem sabe me dizer porque????Obrigado!!!

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.