Javascript HTML表单发回并下载文件时显示进度掩码
我是javascript和HTML的新手。我正在工作,以显示繁忙的图像,而我的html表单是发回和下载文件。我正在使用插件。我正在使用IE9。我正在发回一份表格,作为回报,我收到了一份文件 当我发回邮件时,我看到忙掩码,然后(要求我另存为文件),但掩码没有消失。没有调用成功/错误回调。下面是我的代码的快照 非常感谢您在解决此问题时提供的指导Javascript HTML表单发回并下载文件时显示进度掩码,javascript,html,Javascript,Html,我是javascript和HTML的新手。我正在工作,以显示繁忙的图像,而我的html表单是发回和下载文件。我正在使用插件。我正在使用IE9。我正在发回一份表格,作为回报,我收到了一份文件 当我发回邮件时,我看到忙掩码,然后(要求我另存为文件),但掩码没有消失。没有调用成功/错误回调。下面是我的代码的快照 非常感谢您在解决此问题时提供的指导 `frmExport.html <head> <script src="js/jquery-1.8.0.js"></scrip
`frmExport.html
<head>
<script src="js/jquery-1.8.0.js"></script>
<script src="js/jquery.form.js"></script>
<script src="js/frmExport.js"></script>
</head>
<body onload="......">
<form id="frmExport" onsubmit="return exportFile();" enctype="multipart/form-data" method="post">
<fieldset>
<legend class="cuesGroupBoxTitle">Export File</legend>
<table border="0" cellpadding="0" cellspacing="8">
<tr>
<td width="50%">Export File:</td>
<td><input type="submit" id="ExportFileButton" value="Export" /></td>
</tr>
</table>
</fieldset>
</form>
</body>
frmExport.js
function exportSuccess(responseText, statusText, xhr, $form)
{
hideMask("exportFile");
alert(statusText");
}
function exportError()
{
hideMask("exportFile");
alert("An error occurred while exporting file.");
}
function exportFile()
{
if(confirm("Exporting file may take sometime. Do you want to continue?"))
{
var options =
{
type: "POST",
success: exportSuccess, // post-submit callback
error: exportError,
url: 'exportURI',
dataType: 'text'
};
// bind to the form's submit event
$('#frmExport').submit(function()
{
$(this).ajaxSubmit(options);
showMask("exportFile");
//always return false
return false;
});
}
}`
`frmExport.html
导出文件
导出文件:
frmExport.js
函数exportSuccess(responseText、statusText、xhr$form)
{
hideMask(“导出文件”);
警报(状态文本);
}
函数exportError()
{
hideMask(“导出文件”);
警报(“导出文件时出错。”);
}
函数exportFile()
{
如果(确认(“导出文件可能需要一些时间。是否继续?”)
{
变量选项=
{
类型:“POST”,
success:exportSuccess,//提交后回调
错误:exportError,
url:'exportURI',
数据类型:“文本”
};
//绑定到表单的提交事件
$('#frmExport')。提交(函数()
{
$(此).ajaxSubmit(选项);
显示掩码(“导出文件”);
//总是返回false
返回false;
});
}
}`
我很确定您的问题是,在已触发提交时,挂接提交事件($(“#frmExport”)。提交(…)
。请尝试将其挂接到文档上。就绪
$(document).ready(function() {
var options =
{
type: "POST",
success: exportSuccess, // post-submit callback
error: exportError,
url: 'exportURI',
dataType: 'text'
};
// bind to the form's submit event
$('#frmExport').submit(function()
{
$(this).ajaxSubmit(options);
showMask("exportFile");
//always return false
return false;
});
});
我在HTML页面上也有其他表单。我应该把它写在哪里?在标题部分?在$(文档).ready函数在调用页面之前等待页面完全加载,因此您可以将其放在标题部分,但也可以将其放在其他适合您需要的位置,并且仍将在正确的时间调用。它没有帮助。我不确定是否做错了什么。我将其复制到标题部分。我重新加载了页面,它给出了正确的结果me确认消息。1.从表单标签2中删除onsubmit。已更改
现在我的成功回调被调用,但IE不要求另存为文件。