Skip to content

Instantly share code, notes, and snippets.

@dangerouse
Created January 12, 2012 18:55
Show Gist options
  • Save dangerouse/1602370 to your computer and use it in GitHub Desktop.
Save dangerouse/1602370 to your computer and use it in GitHub Desktop.
Very simple jQuery Ajax form
<div>A new bit of data added.</div>
<!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