JavaScript how to make div visible using jquery? make image visible using javascript,make div visible using jquery,

 function showwaitmsg() {
        $("#wait").fadeIn();
        return  true;
    }
    function hidewaitmsg() {
        $("#wait").fadeOut();

    }

    $("a:contains('Test1')").bind("click", function () {
      if (showwaitmsg())
        test2(); // Function contains XMLHttpRequest
        hidewaitmsg();
    });


   <div id="wait" class="overlay" style="display: none">
             Please Wait
        <img src="~/loading.gif" />
    </div>

I am trying to show a "please wait" message using the above code while the XMLHttpRequest is being processed. The wait div is showing up too late after the request has been processed. Can you please tell me what I should do to make the wait div visible as soon as the test1 button is clicked?

Answer:1

Instead of calling showwaitmsg() and hidewaitmsg() outside of test2(), you should include them inside your ajax call.

$.ajax({
    ...,
    beforeSend: showwaitmsg(),
    ...,
    complete: hidewaitmsg()
});

Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request. It is also worth noting that complete is called after success and error callbacks are executed.

Answer:2
$("#id_of_button").on('click', function() {
    $("#wait").show();
});
Answer:3

So I have a menu on a screen where there are several identical boxes - the only difference is that the boxes are numbered differently. <div id="1"> <select name="option1"> &...

So I have a menu on a screen where there are several identical boxes - the only difference is that the boxes are numbered differently. <div id="1"> <select name="option1"> &...

I'm trying to check when a div is reached from scrollbar with jquery. I read some similar question on stackoverflow, but all are on one div only. I have 4 div, with height: 100% and I want know when ...

I'm trying to check when a div is reached from scrollbar with jquery. I read some similar question on stackoverflow, but all are on one div only. I have 4 div, with height: 100% and I want know when ...

I'm trying to create a stripe customer using parse but can't seem to get the customer.id value from the response. var newCustomer; Stripe.Customers.create( card: request.params.cardToken, ...

I'm trying to create a stripe customer using parse but can't seem to get the customer.id value from the response. var newCustomer; Stripe.Customers.create( card: request.params.cardToken, ...

  1. creating stripe customer
  2. stripe creating customer object

I have a controller for uploading a file of any type. A condensed version of it is [HttpPost] public ActionResult Index (HttpPostedFileBase file, string selectedOrgName, string ...

I have a controller for uploading a file of any type. A condensed version of it is [HttpPost] public ActionResult Index (HttpPostedFileBase file, string selectedOrgName, string ...