[英]sapui5 how to provide Busy Indicator for Synchronous Ajax GET request
Im facing an issue in getting Busy Indicator while firing a synchronous request
.我在触发
synchronous request
时遇到了获取Busy Indicator的问题。 But for asynchronous request
iam able to see Busy Indicator .但是对于
asynchronous request
能够看到Busy Indicator 。 But my business requirement will not accpet async request
here.但是我的业务需求不会在这里接受
async request
。
I checked in many blogs to find a solution , But unfortunately im not able to get solution.我查看了许多博客以找到解决方案,但不幸的是我无法获得解决方案。
Can someone please help me to provide Busy Indicator for synchronous request
.有人可以帮我提供
synchronous request
忙指示器吗?
Below is my code..下面是我的代码..
sap.ui.core.BusyIndicator.show(0); // Not working
new sap.m.BusyDialog().open(); // Not working
var settings = {
"async": false, // If i change to true i can see busy indicator
"crossDomain": true,
"url": "URL", // URL of my App
"method": "GET",
"headers": {
"cache-control": "no-cache"
}
};
var that = this;
$.ajax(settings).done(function (response) {
sap.ui.core.BusyIndicator.hide(0);
});
Title indicates using a UI5 model, given code is using query... question is a bit unclear.标题表示使用 UI5 模型,给定代码使用查询...问题有点不清楚。
Code is for a read using bindings(here V4, I think v2 has the same events), and setting the view busy during the request (that's an async request)代码用于使用绑定读取(这里是 V4,我认为 v2 具有相同的事件),并在请求期间将视图设置为忙碌(这是一个异步请求)
this.getView().bindElement({
path: "/" + sObjectPath,
events: {
dataRequested: function() {
that.getView().setBusy(true);
},
dataReceived: function() {
that.getView().setBusy(false);
}
}
});
The V2 model supports also direct request (that's an async request) : V2 模型还支持直接请求(即异步请求) :
const that = this;
that.getView().setBusy(true);
oModel.read("/path", {
success: function (oData) {
that.getView().setBusy(false);
}
});
The same works with jQuery Ajax API (that's an async request) .同样适用于 jQuery Ajax API (这是一个异步请求) 。
const that = this;
that.getView().setBusy(true);
$.ajax(settings).done(function (response) {
that.getView().setBusy(false);
});
Sync http-requests are deprecated .不推荐使用同步 http 请求。 Sync would mean the UI is freezing while the request is running.
同步意味着用户界面在请求运行时冻结。 Obviously, this is nowadays not desired.
显然,这是当今所不希望的。 Some browsers dropped already support.
一些浏览器已经放弃支持。 As it was already pointed out by others.
正如其他人已经指出的那样。 Keep in mind there is just one thread for your JS.
请记住,您的 JS 只有一个线程。 See also
见还
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.