我有以下代码在浏览后读取文件名并使用 POST 将其发送到另一个页面。如果我在 $.post 之后有警报,那么它工作正常。如果我删除警报消息,则 post 不会将文件名转发到另一个页面。
<input type="file" name="fileupload" id="fileupload" value="">
// 查询代码
$("#fileupload").change(function() {
if ($("#fileupload").val().length > 0) {
$.post("ReadExcel.jsp", {
filename: $("#fileupload").val(),
processId: < %= processId % >
});
alert($("#fileupload").val()); // **If I remove this alert, then the code doesn't works**
}
location.reload();
});