Guest User

Untitled

a guest
Dec 12th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.79 KB | None | 0 0
  1. <?php
  2. if(isset($_GET['api_fb'])) {
  3.  sleep(3);  // simule la latence
  4.  $json = array('retour' => array('data' => true));
  5.   echo json_encode($json);
  6. }
  7. else {
  8. ?>
  9. <html>
  10. <head>
  11.   <title></title>
  12.   <meta charset="utf-8">
  13. </head>
  14. <body>
  15.   <button class="facebookUpload">Valider</button>
  16. </body>
  17. <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  18. <script>
  19. $(document).ready(function() {
  20.  
  21.   function getAlbum() {
  22.     console.log('Appel API FB, latence ...');
  23.     return $.get('?api_fb');
  24.   }
  25.  
  26.   $('.facebookUpload').on('click', function() {
  27.     promise = getAlbum();
  28.     promise.then(function(res) {
  29.       console.log('Retour API FB', res);
  30.       console.log('Le traitement à effectuer');
  31.     });
  32.   });
  33.  
  34. });
  35. </script>
  36. </html>
  37. <?php
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment