Create a gist now

Instantly share code, notes, and snippets.

Embed
Scortes - jQuery, AJAX integration
<html lang=cs><head><meta charset=utf-8 /></head><body>
<ul class="teams">
<li><a href='https://scortes.rozpisyzapasu.cz/api/533A1A/2015/Morašice/status.html'>Muži</a></li>
<li><a href='https://scortes.rozpisyzapasu.cz/api/530C2B/2015/H. Újezd/Morašice/status.html'>Dorost</a></li>
<li><a href='https://scortes.rozpisyzapasu.cz/api/533E2A/2015/Morašice/status.html'>Žáci</a></li>
</ul>
<div id="scortes"></div>
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
(function() {
preloadFirstTeam();
loadResultsOnClick();
function preloadFirstTeam() {
loadResults($('.teams li:first-child a'));
}
function loadResultsOnClick() {
$('.teams a').click(function(e) {
e.preventDefault();
loadResults($(this));
});
}
function loadResults(link) {
var url = link.attr('href');
$.get(url).then(function (data) {
$('#scortes').html(data);
}).fail(function () {
alert('Výsledky se nepodařilo načíst');
});
}
}());
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment