Created
March 15, 2014 01:58
-
-
Save cflove/9560775 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 lang="en"> | |
| <head> | |
| <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script> | |
| <meta charset="UTF-8"> | |
| <title>Ajax Call</title> | |
| <style type="text/css"> | |
| body {font-family: Verdana; font-size: 14px} | |
| .rabbits {cursor: pointer; color: red;} | |
| #AboutRabbits {padding: 20px;} | |
| </style> | |
| </head> | |
| <body> | |
| Meet our Rabbits : | |
| <span class="rabbits" data-url="Peter">Peter</span> . | |
| <span class="rabbits" data-url="Benjamin">Benjamin Bunny</span> . | |
| <span class="rabbits" data-url="Cotton-Tail">Cotton-Tail</span> . | |
| <span class="rabbits" data-url="Mrs-Rabbit">Mrs. Rabbit</span> | |
| <div id="AboutRabbits">Click On Rabbit's Name to See More</div> | |
| <script type="text/javascript"> | |
| $(document).ready(function(){ | |
| $('.rabbits').click(function() { | |
| // $('body').on('click','.rabbits', function() { | |
| $.ajax({ | |
| url: "http://localhost/"+ $(this).attr('data-url')+'.html' | |
| }).success(function(data) { | |
| $('#AboutRabbits').html(data) | |
| }); | |
| }) | |
| }) | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment