Created
July 24, 2011 18:26
-
-
Save TannerRogalsky/1102913 to your computer and use it in GitHub Desktop.
Injecting only part of a remote page into the DOM via jQuery AJAX get request.
This file contains hidden or 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
<html> | |
<head> | |
<script src="jquery-1.6.2.js"></script> | |
</head> | |
<body> | |
<script> | |
$(document).ready(function() { | |
$.ajaxSetup ({ | |
cache: false | |
}); | |
$('a').click(function(){ | |
$.get( | |
"index2.html", | |
function(responseText){ | |
$("#result").html(responseText); | |
$("#remove").remove(); | |
}, | |
"html" | |
); | |
}); | |
}); | |
</script> | |
<div id="result"><a href="#">Click Me!</a></div> | |
</body> | |
</html> |
This file contains hidden or 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
<html> | |
<head> | |
</head> | |
<body> | |
Hello, World! | |
<div id="remove">Test.</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment