开发者

Using jquery ui dialog with jquery ajax

开发者 https://www.devze.com 2023-01-09 05:08 出处:网络
I want a modal dialog that says \"Please wait, calculating\", to appear while jquery.ajax is calculating the price of products, so as not to annoy users. I tried the ajaxStart() and ajaxStop() functio

I want a modal dialog that says "Please wait, calculating", to appear while jquery.ajax is calculating the price of products, so as not to annoy users. I tried the ajaxStart() and ajaxStop() functions but it's not working properly. Please can someone give me some advice on what I'm doing wrong?

Here's the code:

var form = document.forms["orderDefinition"];
开发者_如何学C
form.elements["formChangeRequest"].value = "true";
$.ajax({
  type: "POST",
  url: "ajax/possibleValues.html",
  data: $("form#orderDefinition").serialize(),
  success: function(response){
    $('#usercontent .sleeve .toprow').html(response);
    applyValidation();
  }
});

$("#waitingMsg").ajaxStart(function(){
      $(this).dialog({modal: true});
  }).ajaxStop(function(){
      $("#waitingMsg").hide();
 });

Many thanks


You can use 'beforeSend' and 'complete' callbacks of .ajax()

From the documentation,

"beforeSend is called before the request is sent, and is passed the XMLHttpRequest object as a parameter. complete is called when the request finishes, whether in failure or success."

0

精彩评论

暂无评论...
验证码 换一张
取 消