我有一个提交给 JavaScript 的 HTML 表单,处理数据并将 POST 请求发送到 PHP 脚本。
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
if(contentElt && xmlHttp.responseText) {
var ajaxData = JSON.parse(xmlHttp.responseText);
var processedResultCount = parseInt(ajaxData[0]);
totalResultCount += processedResultCount;
contentElt.innerHTML = "Date processed (month - year): " + recupMonth + " - " + recupYear + "<br/>Results processed: " + processedResultCount + "<br/>Total results processed: " + totalResultCount;
pageNum++;
writeMode = "a";
if(processedResultCount === 0) {
pageNum = 1;
recupMonth--;
if(recupMonth === 0 && recupYear > endYear) {
recupMonth = 12;
recupYear--;
}
else if(recupMonth === endMonth && recupYear === endYear) {
alert("Processing finished");
if(totalResultCount != 0) {
contentElt.innerHTML = "Total processed results: " + totalResultCount + '<br/><br/>> <a href="amazon_keyword_stats.csv" title="Download CSV result file">Download CSV result file</a>';
}
return;
}
}
当我达到条件时
else if(recupMonth === endMonth && recupYear === endYear)
并且条件满足。代码进不去。
继续递减月份,当它达到 -2 时,它仍然执行五次迭代,然后代码 arette 不提供 CSV 下载。
我不明白为什么会这样,有人会有线索吗?