Created
January 12, 2012 18:55
-
-
Save dangerouse/1602370 to your computer and use it in GitHub Desktop.
Very simple jQuery Ajax form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div>A new bit of data added.</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>index</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
</head> | |
<body> | |
<form> | |
<input type="submit" id="add_link" value="Add" /> | |
</form> | |
<div id="data_view"> | |
<div>Some pre-existing data is here.</div> | |
<!-- new data will go here --> | |
</div> | |
<script type="text/javascript"> | |
jQuery('#add_link').click(function(){ | |
jQuery.ajax({ | |
url:"create.html", | |
success:function(data) { | |
$('#data_view').append(data); | |
} | |
}); | |
return false; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment