我希望在加载链接时获得extjs的watingmessage。响应是二进制代码,我想要下载。该链接例如是“test.php”。
function loadurl(link){
Ext.MessageBox.wait('Loading ...');
Ext.Ajax.request({
url: link,
callback: function(options, success, response){
Ext.MessageBox.updateProgress(1);
Ext.MessageBox.hide();
if (success) {
// response : my attachment
}
else {
}
},
scope: this
});
}
{
...
//functioncall
loadurl('test.php');
}
我也试过test.php。
<?php
header('Content-Disposition: attachment; filename="'.$filename.'"');
echo $content;
?>
但它不起作用。如果我只是加载链接它可以工作,但没有等待消息。
答案 0 :(得分:1)
在ExtJS Documentation中有一个名为LoadMask
的类,用于显示加载'微调器'以及短消息。在你的情况下,你会这样使用它:
function loadurl(link){
var mask = Ext.LoadMask(Ext.getBody(), {msg:"Loading..."})
mask.show();
Ext.Ajax.request({
url: link,
callback: function(options, success, response){
if (success) {
// response : my attachment
}
else {
}
//do whatever work we need to do, then hide the mask
mask.hide()
},
scope: this
});
但是,如果由于某种原因,回调几乎立即回来,那么掩码可能不可见,因为您的文件加载速度太快。如果这是一个问题,您可以通过将Ajax请求放在setTimeout
。