Good day. The situation is this: There is a server. It has a link by clicking on which content is generated (DJVU is distilled into TIFF) and a TIFF file is issued. The generation takes a long time. Up to a minute (all this time in the browser is written "Waiting% host%"). Then the "save as" window pops up and the finished file is downloaded. Question: Is it possible to generate an informational message at the time of generation (from a click to the "save as" window) (for example, to twist the GIFC from the beginning, and remove it from the window)? I would like, if possible, through jQuery AJAX. But I create an AJAX request, send it, return an answer, success is triggered, but “save as” does not occur. Can I somehow explain to him that it would be nice to save all this? I hope clearly explained. Thanks for the answers and for participating.

UPD From the server is a picture TIFF. But she comes in a minute. This minute must be caught. If you apply this code

$.post(URL, PARAMS, function(data) { alert(data.length); }); 

Then by request you can enable the GIF, close it by success, but how to make its incoming data save to a file? Alert falls out and that's it. Infu must somehow continue to save. If you use the old way of sending via FORM, then the URL is changed to the file and I don’t see how to catch the appearance of "save as".

  • one
    @QuitLN, According to the rules of the forum, questions should not be limited to solving or completing student assignments. Please clarify what you have done yourself and what did not work out. What exactly are you taking from the server? Parsish ready link after waiting, or how? - Artem
  • What is the server side? Php - MuFF
  • Unfortunately not. Samopisny server. But basic features are available. - QuitLN


1 answer 1

Maybe this solution will suit you:

From the page you call ajax request to generate a picture, and in the background wait for an answer, but in the answer you don’t give the picture itself, but the link to it, and in the success method you write location=data

 $.ajax({url:"you url for generation"}).success(function(data){ location = data; }); 

More precisely, you probably need to create a new window with this location:

 window.open(data,'','…'); 

Well, respectively, all sorts of twists turn on and off before calling Ajax and in Suksess.

Through frames, everything is perfectly caught:

can see here

HTML

 <button>test</button> <div id="loader"></div> <div class="iframe"> <iframe></iframe> </div> 

Js

 $(document).ready( function(){ $("button").click(function(){ $("#loader").text("Loading..."); $("iframe").ready(function(){$("#loader").text("Loading... started...");}); $("iframe").load(function(){$("#loader").text("Loaded!");}); $("iframe").attr("src","http://jfarcand.files.wordpress.com/2012/05/untitled.jpg"); }); } );​ 
  • one
    Yes, the method was considered. But the problem is that the picture is not physically stored anywhere. It is generated and immediately issued to the stream. I would like to avoid intermediate storage (I will have to rewrite a lot) :( - QuitLN
  • It’s up to you to decide, but this is a bad decision in principle - the client’s side can wait for a minute to wait for a response from the server as a timeout, depending on the network / browser / proxy / provider settings, etc. Then try to implement through frames? - Chad
  • one
    Through the trouble frames, it’s not possible to catch the start time of the file download = (onload is not going to work = \ - QuitLN
  • See the answer update. - Chad
  • one
    The method is excellent. But as I understand it works only for inline documents. If you substitute to him the .exe file: already in "Loaded!" does not get up. My TIFF-ki just unloaded. Apparently there is no simple solution. Thanks for the help ! - QuitLN