Skip to content

Instantly share code, notes, and snippets.

@JJ
Created January 25, 2012 11:15
Show Gist options
  • Save JJ/1675859 to your computer and use it in GitHub Desktop.
Save JJ/1675859 to your computer and use it in GitHub Desktop.
Prueba con JQuery para el taller de Ajax de la OSLUGR. Un ejemplo mínimo de uso de Ajax con JQuery
$(function(){
$("a.ajax").click((function(){
$.get($(this).attr('href'), function(data){
alert("Ya");
})
.success(function(data){
alert( 'Lo hise' )})
.error(function(data){
alert( 'Pos no' )})
.complete(function(data){
alert( 'Hecho' )})
}
));
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>a.ext {font-weight:bold; color:magenta}</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js'></script>
<script type='text/javascript' src='ej12.js'></script>
<title>Pruebas JQuery</title>
</head>
<body>
<h1>Prueba probando Ajax</h1>
<p><a class='ajax' href='buena.html'>Buena</a> y <a class='ajax'
href='mala.html'>Mala</a> </p>
<div id='contenido' style='border:1px solid black' >
</div>
<hr>
<!-- hhmts start -->Last modified: Wed Jan 25 11:40:14 CET 2012 <!-- hhmts end -->
</body> </html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment