-
-
Save mjesusabarca/2fba5eeba683f0a5c639ad37789677a5 to your computer and use it in GitHub Desktop.
You've decided you only want to get photos of london. Use the data option of the $.ajax function to pass a location option. Get the location from the data-location on the #tour element using the data method.
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
| DOM : | |
| <div id="tour" data-location="london"> | |
| <button>Get Photos</button> | |
| <ul class="photos"> | |
| </ul> | |
| </div> | |
| JS: | |
| $(document).ready(function() { | |
| var el = $("#tour") | |
| el.on("click", "button", function() { | |
| $.ajax('/photos.html', { | |
| data: {location: el.data('location')}, | |
| success: function(response) { | |
| $('.photos').html(response).fadeIn(); | |
| } | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment