Last active
May 1, 2017 22:08
-
-
Save lnmunhoz/6504537 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 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