Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['api_fb'])) {
- sleep(3); // simule la latence
- $json = array('retour' => array('data' => true));
- echo json_encode($json);
- }
- else {
- ?>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8">
- </head>
- <body>
- <button class="facebookUpload">Valider</button>
- </body>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
- <script>
- $(document).ready(function() {
- function getAlbum() {
- console.log('Appel API FB, latence ...');
- return $.get('?api_fb');
- }
- $('.facebookUpload').on('click', function() {
- promise = getAlbum();
- promise.then(function(res) {
- console.log('Retour API FB', res);
- console.log('Le traitement à effectuer');
- });
- });
- });
- </script>
- </html>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment