JavaScript Wait until ajax script is finished than show the page wait until ajax is finished,wait until ajax call is

I have a script that i used in my php page this is the script :

<script>
    $(document).ready(function() {
        $.ajax({
            url:"http://www.exemple.com/jsonp?j=123",
            dataType: 'jsonp', // Notice! JSONP <-- P (lowercase)
            success:function(data){
                // I get data and i sendit to test
                $.ajax({
                    url: 'test/' + data,
                    type : 'POST',
                    complete: function(){
                        // the function test is complete
                    },
                });
            }},
        });
    });
</script>

The problem is that my page shows just after the first ajax call, so i want it to be shown until the second ajax call takes effect !!!

Answer:1

Firstly place a div over the site, something like this:

<div id="overlay">
    Loading...
</div>
#overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: #FFF;
    z-index: 9999;
}

Then in the complete callback of the second AJAX call, remove that overlay once your UI has been set up.

complete: function(){
    // the function test is complete

    $("#overlay").fadeOut();
}
Answer:2

I have a date input <input type="date" id="a" name="a" required /> Now i want its value to be set by user but it has to be set only after two days of current day, how do i do that using ...

I have a date input <input type="date" id="a" name="a" required /> Now i want its value to be set by user but it has to be set only after two days of current day, how do i do that using ...

  1. validate date input javascript
  2. validate date input python
  3. validate date input
  4. validate date input jquery
  5. validate date input html
  6. validate date input java
  7. validate date input php
  8. validate date input c#
  9. validate date input angular
  10. validate date input laravel
  11. validate input date format in java
  12. validate input date angularjs
  13. validate input date format
  14. validate date field in javascript
  15. check date input javascript
  16. validate date field in jquery
  17. validate date field
  18. check date input java
  19. validate date field in oracle
  20. validate date field in servicenow

I'm using jQuery validator and jQuery 1.8.3. For some reason my form is submitted twice which causes errors. This is the code: someNameSpace.myValidateFunction = function(){ $('#myForm').validate(...

I'm using jQuery validator and jQuery 1.8.3. For some reason my form is submitted twice which causes errors. This is the code: someNameSpace.myValidateFunction = function(){ $('#myForm').validate(...

  1. jquery validation submit invalid form
  2. jquery validate form still submits

Our applications loading process is lengthy, so to provide the user with indication the app is functioning and merely loading, we want to provide a loading/initializing indicator. I tried using WL's ...

Our applications loading process is lengthy, so to provide the user with indication the app is functioning and merely loading, we want to provide a loading/initializing indicator. I tried using WL's ...

I have the following simple example, When the line extends outside the rectangle, I want to clip it. I already have the rectangle used as an outline, what is a simple way to the same rectangle as a ...

I have the following simple example, When the line extends outside the rectangle, I want to clip it. I already have the rectangle used as an outline, what is a simple way to the same rectangle as a ...