ベロコードでロック画面を行うことができ、Uは簡単にできますダウンロードが完了するまであなたのUIをロックする、残念ながらajaxコールを使用してダウンロードファイルを有効にする方法は2通りありますが、いくつかのhtml要素を追加すると、jquery-ajax自体でダウンロードを有効にできます。 jqueryがダウンロードを終了するまであなたのUIをロックしてください。
方法1
その名を送信AJAXで、応答でこのメソッドを呼び出し
任意の一時ロケーションにXL(ファイル)を生成し、そのファイルを保存するの背後にあるコードを使用しますあなたが保存したファイル
<a>
タグをjqueryに作成し、clickイベントを有効にしてファイルをダウンロードします。
ダウンロードを終えた後のuはあなたのUI
$.ajax({
type: "POST",
url: AQ.AMT.Url + "/Home/StoreImage",
//async: false,
data: JSON.stringify({ request: request }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (Data) {
var _tempPPT = AQ.AMT.Url + "/Download/Temp/" + Data.Result + ".pptx";
// Trick for making downloadable link
a = document.createElement('a');
a.href = _tempPPT;// window.URL.createObjectURL(xhttp.response);
a.id = "idanchrPPT";
// Give filename you wish to download
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd
}
if (mm < 10) {
mm = '0' + mm
}
today = dd + '/' + mm + '/' + yyyy;
if (flipName == "")
a.download = "" + name + "-" + today + ".pptx";
else
a.download = "" + name + "-" + flipName + "-" + today + ".pptx";
a.style.display = 'none';
document.body.appendChild(a);
a.click();
$("#idanchrPPT").remove();
//deleting the file
var deleteFiles = {};
deleteFiles.FilePath = Data.Result;
setTimeout(function() {
$.ajax({
type: "Post",
data: JSON.stringify({ deleteFiles: deleteFiles }),
url: AQ.AMT.Url + "/Home/DeleteExportedPPt",
async: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
},
error: function (result) {
}
});
}, 1000);
},
error: function (e) {
}
});
方法2
使用XMLHttpRequestの代わりにjQueryの$アヤックスのロックを解除することができます
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
var a;
if (xhttp.readyState === 4 && xhttp.status === 200) {
var _tempPPT = AQ.AMT.Url + "/Download/Template/ExportPPtTrend1.pptx";
// Trick for making downloadable link
a = document.createElement('a');
a.href = _tempPPT;// window.URL.createObjectURL(xhttp.response);
a.id = "idanchrPPT";
var k = xhttp.responseText;
// Give filename you wish to download
a.download = "test-file.pptx";
a.style.display = 'none';
document.body.appendChild(a);
a.click();
$("#idanchrPPT").remove();
//alert("ok");
$('.divLoader,.divBackgroundCo').hide();
}
};
// Post data to URL which handles post request
xhttp.open("POST", urlToHandler);
//Send the proper header information along with the request
xhttp.responseType = 'text';
//xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send();