SJoy
SJoy

Reputation: 142

Pass a Value to AjaxStart Event

I am using ajaxStart() in order to load a loading popup screen for every AJAX call. The text I have given in the popup is loading! Please wait.

I need to change the text based on the screen. For example I have a screen which is doing some calculations on an AJAX call. Then the popup should be like System is doing the calculation! Please wait.

How can I do this using the ajaxStart() functionality?

$(document).ajaxStart(function() { 
  $("#modal").modal('show') 
})

Upvotes: 5

Views: 832

Answers (1)

Jins Peter
Jins Peter

Reputation: 2469

You can use a global varible in the file and change the value of the variable every time you send a request;

    var messageVar ="Loading.. Please Wait..!!";

    $( document ).ajaxStart(function() { 
    //use messageVar here for your reqmnt;

      $( "#modal" ).modal('show');
      $( "#modal" ).append('<div>'+messageVar +'</div>');

    });.

Before ajax call request you can set messageVar

Upvotes: 4

Related Questions