closer to getting ajax to work

This commit is contained in:
Michael Q Larson
2014-11-06 17:38:47 -08:00
parent 944f4d6a1d
commit 86d433aaba
5 changed files with 71 additions and 56 deletions

View File

@@ -4,10 +4,27 @@ $(document).ready(function() {
$('.challenge-content').removeClass('hidden-element').addClass('animated fadeInDown');
});
$('.completed-challenge').on("click", function() {
// user.completedChallenges.push()
$('#complete-dialog').modal('show');
});
$('.skip-challenge').on("click", function() {
$('#skip-dialog').modal('show');
});
});
$('.complete-button').on("click", function() {
l = location.pathname.split('/');
$.ajax({
type: 'POST',
data: l,
url: '/completed_challenge',
success: function(data) {
console.log('success');
console.log(JSON.stringify(data));
}
});
window.location = "/challenge?=" + (parseInt(l[l.length-1]) + 1)
});
$('.skip-button').on("click", function() {
l = location.pathname.split;
window.location = "/challenges/" + (parseInt(l[l.length-1]) + 1)
});
});