Skip to content

Instantly share code, notes, and snippets.

@atomize
Created March 1, 2012 07:00
Show Gist options
  • Save atomize/1947929 to your computer and use it in GitHub Desktop.
Save atomize/1947929 to your computer and use it in GitHub Desktop.
jQuery form hijack anchor href (link) ajax
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript" src="http://malsup.github.com/jquery.form.js"></script>
<script>
$(document).ready(function(){
$('a').bind('click',function(event){
event.preventDefault();
$.get(this.href,{},function(response){
$('#response').html(response)
})
})
});
</script>
<style type="text/css">
#response { width:100%; height: 400px; background-color:#CCE0FF; overflow-x:hidden;
}
</style>
</head>
<body>
<div><a href="http://www.github.com"/>Hijack GitHub</a></div>
<div id="response"></div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment