PDA

View Full Version : Use Ajax to return downloadable file content?



clarkeligong
19 Mar 2011, 2:21 AM
hi, is that possible to use AJax return file content instead of url?
Here is my case:


Ext.Ajax.request({
url : 'FileServlet',
success: function(response) {
//the obj variable responseText supposes to contain file content!
var obj = Ext.util.JSON.decode(response.responseText);
try {
Ext.destroy(Ext.get('downloadIframe'));
}catch(e) {}
Ext.DomHelper.append(document.body, {
tag: 'iframe',
id:'downloadIframe',
frameBorder: 0,
width: 0,
height: 0,
css: 'display:none;visibility:hidden;height:0px;',
src: obj
});
}
});


But it doesnot work and show me the "syntax error" error. Any tips?