问题描述
我正在尝试显示来自 Ajax 调用的长时间运行进程的周期性状态。问题是只有第一个 response.clear 有效。当我在第一次清除后刷新时,我得到了前面的所有输出,而不仅仅是清除后的输出。
在生产代码中,我求助于输出“||”每次写入后分解响应,然后在“||”上拆分并获取该数组中的最后一个元素。但是,我不想这样做。
Ajax 调用:
$(document).on(`dragover drop`,`#AmazonListingReport`,function(e) {
$(`#AmazonListingReportrMsg`).text(``);
e.stopPropagation();
e.preventDefault();
files = [];
if (e.type === `drop`) {
form_data = new FormData();
file = e.originalEvent.dataTransfer.files[0];
form_data.append(`txtFile`,file);
form_data.append(`action`,`processAmazonAllListingsFile`);
let statusText = `Uploading`;
updateStatus($(`#AmazonListingReportrMsg`),statusText);
$.ajax({
xhr: function() {
let myXhr = new XMLHttpRequest();
myXhr.addEventListener(`progress`,function() {
if (statusText !== myXhr.responseText) {
statusText = myXhr.responseText;
console.log(`update status`,statusText);
clearInterval(updateStatusTimer);
updateStatus($(`#AmazonListingReportrMsg`),statusText);
}
},false);
if (myXhr.upload) {
myXhr.upload.addEventListener(`progress`,function(e) {
if (e.lengthComputable) {
$(`#processprogress`).attr({
value: e.loaded,max: e.total,});
}
},false);
}
return myXhr;
},url: `KP_ManageAmazonSeasonalOrders_AJAX.asp`,data: form_data,cache: false,contentType: false,processData: false,enctype: `multipart/form-data`,type: `POST`,}).done(function(data) {
console.log(`data`,data);
}).fail(function(xhr,textStatus,errorThrown) {
console.log(xhr,errorThrown);
}).always(function() {
clearInterval(updateStatusTimer);
});
}
});
过程:
sub processAmazonAllListingsFile()
response.write "You should never see this"
response.clear '<---this works. I never see the above string
response.write "Starting"
response.write vbCrLf
response.flush '<--This works. Returns "Starting"
response.clear
'<LONG RUNNING PROCESS HERE>
response.write "converting file"
response.write vbCrLf
response.flush '<--returns "Startingconvertingfile"
response.clear
'<LONG RUNNING PROCESS HERE>
response.write "Excel File Saved. Updating Products"
response.write vbCrLf
response.flush '<--Here,I get "Startingconverting fileExcel File Saved. Updating Products"
response.clear
'<LONG RUNNING PROCESS HERE>
response.write "done copying to sql server"
response.write vbCrLf
response.flush '<--Here,I get "Startingconverting fileExcel File Saved. Updating Productsdone copying to sql server"
response.clear
response.end
end sub
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)