我想为我的服务器端 ajax 调用实现 Kendo 进度条。我试过了,但它没有在 ajax 调用之前启动,如果我使用下面的 setTimeOut 函数来关闭 ajax 调用,进度条只会显示很短的时间。例如:
setTimeout ( function()
{
kendo.ui.progress($("#progressBar"), false); //close the progress bar
},5000);
在上面的代码中,进度条只显示 5000 毫秒,然后关闭。这是我的实际要求。
我需要有两个 ajax 调用,一个在另一个内部。我想在第一个 ajax 调用启动之前实现进度条,并希望在第二个 ajax 调用完成后关闭。另一种选择是在第一次 ajax 调用启动之前实现进度条,并在第一次调用完成后关闭它,然后为第二次 ajax 调用启动进度条,并在第二次 ajax 调用完成时关闭。
我希望我的要求很明确。如果您需要更多详细信息,请告诉我。这是我的代码:
<div id="progressBar"></div>
<script>
var getResponseFromSOA = function(filterObject, file,verb, callback) {
createFilterString(filterObject, function(filterString) {// get the filter string
if(jQuery) {// check the jQuery file is integrated or not
var headers = {Authorization: COOKIES.readCookie("Authorization"),requestmode:"ACK_URL"};
headers.isRender = file.isRender;
if(file.inputDataHeaders)
headers.inputData = file.inputDataHeaders;
/*
* Since it is async call that's why call will be 2 times.
* 1st time we have to call to the request handler of the SOA.
* In the response we will get one link address of response handler.
* 2nd time we have to call that link what we got from the 1st request.
* Response handler will give actual data in the data property of the response
*/
kendo.ui.progress($("#progressBar"), true); //Here progress bar will initiate
jQuery.ajax({
url: file.fileUrl + "/" + $securityComponent.cryptograghicFunctions.encryptor(filterString),
type: verb,
headers: headers,
async: false,
error : function()
{
console.log("some error occured at getResponseFromSOA submitting the request");
},
success: function(responseDataFromRequestHandler) {
// again call because it is async mode form SOA team
jQuery.ajax({
url: responseDataFromRequestHandler.links[1].href,
async: false,
headers: {Authorization: COOKIES.readCookie("Authorization"),requestmode:"ACK_URL"},
success: function(responseDataFromResponseHandler) {
try {
console.log(responseDataFromResponseHandler);
if(callback) callback(responseDataFromResponseHandler.data);
}catch(e) {
console.log(responseDataFromResponseHandler);
// printing the error message in the console window
console.log("Error in the callback in data-transactor-js > getResponseFromSOA"
+ "\n"
+ e.message);
}
},
complete: function() {
kendo.ui.progress($("#progressBar"), false); //close the progress bar
}
});
},
complete: function() {
kendo.ui.progress($("#progressBar"), false); //close the progress bar
}
});
} else throw {message: "jQuery is not defined or jQuery file is not linked"};
});
};
</script>
提前致谢...