PDA

View Full Version : Why the IE8 can not download file in the Ajax.request event 'success'?



Fent2
24 Dec 2014, 7:54 PM
I want to do download a file after Ajax request,so i use "window.location.href= "url../data.dat" "
to download the file in the Ext.Ajax.request 'success' ,but the IE8 always pod-up a tip : "To help protect your security, Internet Explorer blocked this site from downloading files to your computer",
but if i use 'window.location.href = url' outside the ajax request ,that OK(IE8 no pop up the tip ),
somebody know why ?or have some solution to avoid the pop-up ?
I do not want to modify the IE8 setting ,because this is not a good solution for user.

I use like this:
Ext.Ajax.request({
scope :this,
timeout:60000,
//async:false,
url: 'data/test.json',
success:function(response){
window.location.href= "url.../data/data.dat";
}
});

lumberjack
31 Dec 2014, 7:47 AM
What is the Content-Type returned when you access the"url.../data/data.dat" file? You might try setting the Content-Type to "text/html".

Regards,
Brian

Fent2
4 Jan 2015, 9:51 PM
Thank you ! I try to set the Content-Type to text html ,the IE8 still pop-up the tip; In fact,the FireFox and Chrome ,the file download OK, I want use ajax to request the server to generate a data file, and when generate ok , use the "window.location.href" to download the data file; as the code i show ,this is OK in the FireFox and Chrome ,but may Pop-up a tip to disable the file download in the IE8; I event to try to use synchronous ajax( set the async to false) , but this may make the browser like "dead" during the request time; my code use like this : Ext.Ajax.request(...); ==> async set to false window.location.href = url return from ajax; ===> Ie8 no pop up the tip,but the browser like "dead" ===> during the AJAX request time so i must use asynchronous ; This problem only in the IE8

Fent2
4 Jan 2015, 10:53 PM
Why this forum compress all line to a line ?

lumberjack
5 Jan 2015, 9:22 AM
The following resources may help you resolve the issues your experiencing with Internet Explorer.

Why does Internet Explorer block some file downloads? (http://windows.microsoft.com/en-US/windows-vista/Why-does-Internet-Explorer-block-some-file-downloads)

Automatic Download Blocking (http://msdn.microsoft.com/en-us/library/dd565669(v=vs.85).aspx)

Regards,
Brian

Fent2
5 Jan 2015, 4:36 PM
En,thank you very much!
This look like not about EXTJS!
Maybe this is the IE security police.