I started the loader - I launched an Ajax request to the server - the answer came - I stopped the loader. How can this be done?
- what loader? - etki
- progress bar - hil400k
- Are you fundamentally on pure javascript? Is it possible to use jQuery library? - likerRr
- There is, but I have no idea what event to set it on if I write something like this: Ajax-query (which returns name) if (name) {alert (true); }, then the alert will be executed before the request arrived - hil400k
- > if I write something like this: Ajax-query (which returns name) if (name) {alert (true); }, then the alert will be executed before the ajax request came - this is asynchronous javascript and xml . The key word in this case is ** asynchronous ** / Use callbacks - DreamChild
|
1 answer
Roughly speaking so:
<img class="loader" style="display: none;" src="/img/loader.gif"> <script> $.ajax({ url: 'test.php', beforeSend: function() { $('img.loader').show(); }, complete: function() { $('img.loader').hide(); } }); </script> - Thanks, but how to make the function, which I will write after the ajax request, be executed only after the response from the server comes? - hil400k
- a little step back from the topic, as in JavaScript to make the next function executed after the completion of the first? - hil400k
- @ hil400k callback function callbacker (callback) {callback.apply (this); } - etki
- @ hil400k, add your own function: complete: function () {$ ('img.loader'). hide (); // here} - likerRr
|