Skip to content

Instantly share code, notes, and snippets.

@gnuget
Created February 8, 2009 02:19
Show Gist options
  • Save gnuget/60144 to your computer and use it in GitHub Desktop.
Save gnuget/60144 to your computer and use it in GitHub Desktop.
Simple ajax call in jquery
//Amarramos a las anchors un evento
$(document).ready(function(){
$("a").click(function(){
alert("hola mundo!");
});
});
//hacemos una llamada ajax
$.ajax({
type: "POST",
url: "patito.php",
success: function(msg){
//inyectamos lo que nos regreso la llamada en algún lugar:
$("#div").append(msg);
//regularmente tendríamos aquí que re-ligar los eventos si entre lo que nos regresa
//la llamada ajax vienen alguna etiqueta "a" por ejemplo:
$("a.llamada_ajax").click(function(){
alert("hola mundo");
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment