Bonjour tout le monde,
Je suis un peu perdu dans cette notation de la méthode $.ajax que j'utilise d'habitude autrement :
Question 1 : Ici, on ne met que l'url, sans mettre url: url
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 }); });
Question 2 : Javascript sait que l'unique paramètre est l'url ?
Question 3: Pourquoi l'utilisation des point (.done...), on dirait l'utilisation de WITH en vb
Merci d'avance.
bee
Partager