
GET, METODO DE LLAMADA AJAX
Dos formas de invocar AJAX a través del método GET, en una o dos funciones saparadas
Snippet options
Download: Download snippet as get-metodo-de-llamada-ajax.js.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!
// DOS FUNCIONES | METODO GET function busca(){ //método GET var parametros = "funcion=busca"; parametros+= "&dato=" + dato; parametros+= "&otro=" + otro; ajax = crearInstancia(); if(ajax){ ajax.abort(); var url = "funciones/diario.php?" + parametros; ajax.onreadystatechange=eBusca; ajax.open("GET",url,true); ajax.send(null); }else{alert("No se pudo crear la instancia");} } function eBusca(){//método GET if(ajax.readyState==4){ if(ajax.status==200){ resp= ajax.responseText; re = resp.replace(/\n/g, ""); re = re.split("@@"); } } } // UNA FUNCION | METODO GET function busca(){ //método GET var parametros = "funcion=busca"; parametros+= "&dato=" + dato; parametros+= "&otro=" + otro; ajax = crearInstancia(); if(ajax){ ajax.abort(); var url = "funciones/diario.php?" + parametros; ajax.open("GET",url,true); ajax.onreadystatechange = function() { if (ajax.readyState==1) { alert ("Cargando......."); } //OPCIONAL if (ajax.readyState==4) && (ajax.status==200){ var resp = ajax.responseText; }// (ajax.readyState==4) && (ajax.status==200) }// function() ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); ajax.send(null); return; }else{alert("No se pudo crear la instancia");} }
Create a free my code stock.com account now.
my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!
Find out more and register nowYou can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.