简体   繁体   English

ajax 通话期间没有立即显示进度条

[英]Progress bar is not showing immediately during ajax call

My Requirement:我的要求:

  1. Click on Submit button and hit Ajax call单击提交按钮并点击 Ajax 呼叫
  2. Show progress Bar显示进度条
  3. Once Ajax call is done Hide progressbar一旦 Ajax 调用完成隐藏进度条
  4. Show Extjs.Message.alert(Ajax result) with Ajax result显示 Extjs.Message.alert(Ajax 结果) 和 Ajax 结果

Problem is When I click on submit button it executes below code but doesn't show progress bar immediately and also progress bar is hiding simultaneously with Extjs Message Alert box问题是当我单击提交按钮时,它执行下面的代码,但没有立即显示进度条,并且进度条与 Extjs 消息警报框同时隐藏

function submit() {

  jQuery("#myProgressBar").show();
  Ext.Message.Alert(doAjaxCall());
}



function doAjaxCall() {
  var ajaxResult = null;
  jQuery.ajax({
    url: someUrl,
    data: someData,

    success: function(result) {
      task.delay(1000);

      ajaxResult = result;
    }


  });
  return ajaxResult;
}

If I use below piece of code then only it is showing progress bar otherwise it is not showing progress bar如果我使用下面的代码,那么只有它显示进度条,否则它不显示进度条

var task= new Ext.util.DelayedTask(function() {
  jQuery("#myProgressBar").hide();
});

and task.delay(1000);task.delay(1000); in Ajax call success part在 Ajax 调用成功部分

try this尝试这个

function submit() {
  jQuery("#myProgressBar").show();
  doAjaxCall(aftersuccess);
}

function doAjaxCall(callback) {
  var ajaxResult = null;
  jQuery.ajax({
    url: someUrl,
    data: someData,

    success: function(result) {
     callback(result);
    }


  });
return result;
}

function  aftersuccess(data){
 jQuery("#myProgressBar").hide();
alert(data);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM