Created
July 26, 2016 04:42
-
-
Save davidhaley/efdfe12d9efb812f68de1f6217af7cb2 to your computer and use it in GitHub Desktop.
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
<!doctype html> | |
<html> | |
<head>Ajax Example</head> | |
<body> | |
<section> | |
<h1>Recent Posts</h1> | |
<article> | |
<h2>Post 1</h2> | |
<p>This is post1.</p> | |
</article> | |
<article> | |
<h2>Post 2</h2> | |
<p>This is post 2.</p> | |
</article> | |
<article> | |
<h2>Post 3</h2> | |
<p>This is post 3.</p> | |
</article> | |
<button id="load-more-posts">Lost more posts</button> | |
</section> | |
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script> | |
$(function() { | |
var button = $('#load-more-posts'); | |
button.on('click', function() { | |
$.ajax({ | |
url: 'more-posts.html', | |
method: 'GET', | |
success: function (morePostsHtml) { | |
button.replaceWith(morePostsHtml); | |
} | |
}); | |
}); | |
}); | |
</script> | |
</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
<article> | |
<h2>Post 4</h2> | |
<p>This is post 4.</p> | |
</article> | |
<article> | |
<h2>Post 5</h2> | |
<p>This is post 5.</p> | |
</article> | |
<article> | |
<h2>Post 6</h2> | |
<p>This is post 6.</p> | |
</article> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment