1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| $('#javascript-ajax-button').on('click', function()
{
alert(url);
// send an ajax-request to this URL: current-server.com/songs/ajaxGetStats
// "url" is defined in views/_templates/footer.php
$.ajax(url + "/songs/ajaxGetStats")
.done(function(result)
{
// this will be executed if the ajax-call was successful
// here we get the feedback from the ajax-call (result) and show it in #javascript-ajax-result-box
$('#javascript-ajax-result-box').html(result);
})
.fail(function()
{
// this will be executed if the ajax-call had failed
})
.always(function()
{
// this will ALWAYS be executed, regardless if the ajax-call was success or not
});
}); |
Partager