Fork me on GitHub

jQuery File Download Plugin for Ajax like, feature rich file downloads 155

by

jquery.fileDownload.js Library

jQuery File Download is a cross server platform compatible jQuery plugin that allows for an Ajax-like file download experience that isn’t normally possible using the web.

Features

  • Brings control back to the developer by exposing a “successCallback” and “failCallback” that allows the developer to control the user experience in either situation.
  • In conjunction with jQuery UI a developer can easily show a modal telling the user that a file download is occurring, disband the modal after the download starts or even inform the user in a friendly manner that an error has occurred. See the Demo for an example of this.
  • File downloads don’t occur in the current window’s location bar. This means if a failure or something unexpected happens the user doesn’t leave the current page they are on or even have to see an ugly error message. This is critical for a good user experience especially on a highly Ajax application.

A classic problem with browser file downloads – Error handling

In a general case a file downloads occur after a user clicks an <a href=”location“> link. The href in the instructs the browser to browse to the location indicated. This is equivalent to setting the window.location of a page using JavaScript.

When the response comes back the HTTP response headers can contain many different things (in fact almost anything). Here are some examples:

Normal, HTML Response

The above “Content-Type” indicates to the browser that it should parse the DOM in the response and display it to the user. The location in the user’s location bar changes to reflect the address of the just-downloaded content.

Normal, “File Download” Response

The above “Content-Disposition” indicates to the browser that the server is trying to invoke a file download in the browser. The browser responds by opening up a file download dialog (or ribbon) for the user to download the file. As a convenience when the browser detects a response like this it doesn’t change the address bar so effectively the user stays on the same page.

Failed, “File Download” Response

As you may have guessed from that ugly highlighter color we’ve got trouble here. The response from a file download error is generally no different from a normal HTML response, the only difference here is that is has an error message as HTML content. The browser will now happily replace your existing page and address with the new error message. Not only have we now displayed an ugly error message to the user but we have also caused them to leave whatever page they were on.

Imagine you have created a nearly exclusively Ajax site like Gmail. A response like this from the server will cause your entire DOM to be replaced by an error message. Imagine this happening to you in Gmail and having to load up everything all over again. Ouch! My current role creating the framework for a highly Ajax application (like Gmail) inspired me to write this plugin for all to use – “web applications” is where the web is going anyways so there has to be a better way…

Another classic problem with browser file downloads – “Happy path” user experience

I probably just caught you thinking this: “well so what… my site never has any problems that cause error messages”… fair enough, but consider this:

  • What is the response time of your web site in terms of serving up static files? Is it instantaneous? Is a user going to immediately look in the far corners of their screen for some sort of a spinning indicator or might they get confused or angry based on their technical prowess? Maybe they are looking at one of these? http://www.ict.griffith.edu.au/images/Animation/netscape_anim.gif (I hope not or you’ve got bigger issues)
  • What if you are serving up a dynamically generated file (perhaps a report of SQL data?) based on user input that may take a few seconds. An average user might expect some sort of indication of what is going on. At the very least from a developer’s perspective it’d be nice if it wasn’t easy for them to hammer the download link a few times (to make it faster of course) wasting cycles across an entire n-tiered application.

I’ve got a solution… just use Ajax to download it!

Good idea! Unfortunately this is not possible due to one key problem:

  • JavaScript, by design, doesn’t have the ability to perform lower level tasks on a users computer out of security concerns. Initiating file download prompts is one of these limitations.

You can certainly use an XMLHttpRequest object to download a binary (or otherwise) file but there is nothing you can do to the response to somehow get it saved on the user’s computer. Flash doesn’t have this limitation, but we really don’t want to get into Flash do we?

Enter jQuery File Download

jQuery File Download overcomes all of the aforementioned limitations of a “normal” browser file downloads. Well how the heck does that work? The concept is nothing new in fact: If you browse around the web you will find plenty of forum posts discussing the same technique, I just wasn’t able to find a succinct easy to use plug-in to do it hence my decision to create this plugin. The answer is:

An iframe and cookie

What?! I have to rely on Web .1 technology to make my Web 2.0 Ajax application user friendly? Turns out this is the magic bullet combination to work around normal limitations of file downloads, here’s how:

iframe

An iframe (which is generally a mortal sin of modern web development) can exist in a DOM but in most respects is treated like an entirely different window. By dynamically inserting a hidden iframe into the DOM and setting its location to the desired file path we can initiate a file download just like it was occurring in the main application window. This directly gets us around one of the nasties of file downloads – if an error occurs the user has now been forced off of the page they were on (which may contain an Ajax application like Gmail) to see an ugly error message.

Like a normal file download in the main window an iframe will never fill with content when a successful file download occurs. It simply contains an empty DOM. Well how do we detect what is going on if nothing happens when the file download is successful. Well this is where the cookie comes in:

cookie + iframe

Since the creation of cookies exists in HTTP headers, which is standard fare for all web requests and responses, we can actually write a cookie to indicate that a file download has been initiated properly (instead of an error page). The response from the web server will now look something like this:

While we can’t directly tell if a file download has occurred we can check for the existence of a cookie which is exactly how jQuery File Download works. Once a download is initiated on the iframe a configurable duration poll of cookies and the iframe contents occurs. If the iframe fills with contents then we know a file download has occurred (in most cases, make sure to set a MIME type!). If the cookie gets written then we know to stop polling and kill the iframe because the file download dialog/ribbon has been displayed.

Using jQuery File Download – JavaScript

jQuery File Download is easy to use in the simple case but also allows for various callback options as well. Don’t forget to add the required cookie code in the next section!

Very simple code demo

 

Use of the very simple approach only protects you from the page changing in the event of a file download error. This alone is pretty useful. If an error occurs the user gets an alert() dialog that says  “A file download error has occurred, please try again.” You can see this demoed here under the “Barebones – jquery.fileDownload.js” heading. I wouldn’t recommend using this option given a much better experience is only a few more lines away…

Impractical code demo of commonly used features

This just demos what you could do but I’d highly recommend against it unless you want confused and annoyed users. This will result in an alert() dialog telling you a file download initiation has just occurred for the specified URL. If a failure occurred it will display the attempted URL and error message in a dialog.

Simple rich user experience code demo

You can see this one running at the top of the demo page. In order for the below code to work for you, you will also need jQuery UI installed and an image (if you want) as a downloading spinner.

This code will cause any <a> with class=”fileDownload” like below

that is ever loaded into your site (assuming a globally loaded JavaScript reference) to initiate a “rich user experience”:

  • User is informed of a pending report download via a jQuery UI modal that says “We are preparing your report, please wait…”
  • Success:
    • Modal goes away just as the browser’s file download dialog/ribbon occurs
  • Failure:
    • User is informed of an error in a jQuery UI modal: “There was a problem generating your report, please try again.”

Another plus to this approach is that it degrades gracefully in case the user doesn’t have JavaScript running because an a href certainly better work in any web browser out there! 

 

 

Custom rich user experience code demo

This demo does almost the same thing as above but handles the modals manually by using the callbacks and it uses modal HTML that already exists on the page.

 

 

HTML for jQuery UI Modals (place anywhere on page) 

 

 

Using jQuery File Download – Server Code for Cookie

Only the MVC 3 server code has been tested. Actually if you want to see it running just head over to the demo page. Just make sure to write a cookie in the same HTTP response as the file download occurs with, that results in this HTTP Response Header (using default configuration):

ASP.NET MVC 3

If you are using a Controller Action to serve up your files (I hope you are!) you can very easily enable automatic cookie writing by inheriting your Controllers from a base class that writes the cookie automatically for you. This assumes that you are using MVC helpers for returning “FileResult”s (or derived classes like FileStreamResult). MVC FTW.

 

ASP.NET

Static Code

 

Response-aware code

 

PHP (with example file)

 

That’s it!

Let me know if you have any issues or can think of some nice features to add.

155 thoughts on “jQuery File Download Plugin for Ajax like, feature rich file downloads

  1. Pingback: Focus on PDF(Viewer) in iFrame – jQuery Forum | free pdf download

  2. Reply Ricardum Sep 19, 2014 8:53 am

    Dont work in IE8 .
    The error “null is null or not an object” is thrown

    Any help?

  3. Reply Candida Sep 13, 2014 8:12 am

    Finally i quit my day job, now i earn decent money online you should try
    too, just search in google – slabs roulette
    system

  4. Reply money making programs Sep 7, 2014 1:12 am

    When you start a home business, the first question that
    probably comes to minbd is “how will I ever build my business to earn money and become financially free. You have probably thought long and hard about what you think would be a successful company. Work within a time-frame that allows for your natural attention span and desired work flow.

  5. Reply contoh landing page affiliate Sep 7, 2014 12:54 am

    Ask parents from your neighborhood if you can teach thir children some
    crafts. Friends may want yoou to maoe their unique curtains.

    The start-up money may well be the determining factor.

  6. Reply social media management Dunstable Sep 2, 2014 7:12 am

    For most recent information you have to pay a quick visit internet and on web I
    found this site as a best web site for hottest updates.

  7. Reply Bartholomew Jul 29, 2014 8:18 am

    Any Help for those of us using JSP Technology ? please

  8. Reply Bartholomew Jul 28, 2014 7:55 am

    Hello John i really appreciate your contribution, i am happy about that.please i have some couple of your favor to ask. i am currently testing your sample API with my java app, i am using java-restful web service + glass fish as the server ,i also use jquery Ajax i imbedded into my HTML to consume the restful web service.i tried jQuery file Download API, in my case it dose not work and i do not know how to set the header in this case. please if you wouldn’t mind could you be of help to me in this challenge ? i thank you again for your contribution co-operation in this field.

  9. Reply Malinda Jul 24, 2014 8:40 am

    I see a lot of interesting articles on your website. You have to spend a lot of time writing, i
    know how to save you a lot of time, there is a tool that
    creates unique, google friendly posts in couple of seconds, just type in google – k2 unlimited content

  10. Reply Loghin Tivig Jun 26, 2014 9:59 am

    Hi

    I’m using your plugin to download .txt files from server on click of a button. I’ve attached
    .done(function () { alert(‘File download a success!’); })
    .fail(function () { alert(‘File download failed!’); })

    I don’t get any error but there is no file downloaded. Any idea why?
    I attach the headers response:

    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
    Connection:keep-alive
    Cookie:language=ro; __utma=212744982.1785255340.1395749984.1399903687.1401719385.5; __utmz=212744982.1401719385.5.5.utmcsr=school360dev.school360.co.uk|utmccn=(referral)|utmcmd=referral|utmcct=/resourcespage/index.php; PHPSESSID=lvmaoccvd7su7117ssj82ek4h7; fileDownload=true

  11. Reply Andrada Jun 19, 2014 10:35 am

    Hello,

    I have a controller written in PHP which creates a zip file from some given files and fires up a download dialog in the browser in the template file upon the click of a button. I retrieve back the data from the controller with a jQuery ajax success event which reads the json data provided by the controller. I want to have a progress bar in the template file which reflects the download dialog in real time and which closes when the download is complete. Is this possible with jQuery.fileDownload?

    I set up a cookie in the controller when the zip file and zip url is created, but when I click the button in the template file, the download fires up but the download iframe stops, not reflecting the download process in real time…

    Thank you!

  12. Pingback: Posting a HTML form with AJAX | ideasdiehard

  13. Reply Ramesh May 31, 2014 7:49 am

    Hello ,
    This is Ramesh how to set the Download file path use Jquery

  14. Reply Leslie Lau May 20, 2014 5:06 pm

    Hi,

    I can’t seem to get onSuccess to fire on client side. Server side I do add fileDownload cookie in header.
    This is my Request and Response:

    Request Headersview source
    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:en-US,en;q=0.8
    Connection:keep-alive
    DNT:1
    User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
    Query String Parametersview sourceview URL encoded
    id:96f75f1c7de56f162f2719
    reportId:1b479139-f2f7-4fc7-9e25-c13965666fa0
    lang:
    detail:true
    row:1341
    name:4c Full M0 KSS 615_PANTONE coated
    filter:
    predFilter:
    measFilter:
    order:
    Response Headersview source
    Content-Disposition:attachment; filename=4c Full M0 KSS 615_PANTONE coated.pdf
    Content-Encoding:gzip
    Content-Type:application/octet-stream
    Date:Tue, 20 May 2014 21:46:36 GMT
    Set-Cookie:fileDownload=true; path=/
    Transfer-Encoding:chunked
    Vary:Accept-Encoding, User-Agent

    What else can I do to debug this?

  15. Reply Smith May 18, 2014 5:15 am

    simple and easy, thank you! voted on stakoverflow

  16. Reply Avneesh May 6, 2014 4:06 pm

    Hello,

    I have a form where I am using Jquery validator for server as well as front end validation[AJAX]. Once validations are passed i.e response = SUCCESS, I am creating a dynamic form and calling the method which download a form.
    I have a couple of questions
    1) Is your code below – going to work correctly for dynamic form as well:
    $(document).on("submit", "form.fileDownloadForm", function (e) {
    $.fileDownload($(this).prop('action'), {
    preparingMessageHtml: "We are preparing your report, please wait...",
    failMessageHtml: "There was a problem generating your report, please try again.",
    httpMethod: "POST",
    data: $(this).serialize()
    });
    e.preventDefault();
    });

    2) I am not allowed to use POST as I am getting ethod not allowed error, can I use GET instead of POST in your above code?

  17. Reply women calvin klein boxers May 5, 2014 7:47 pm

    Does your blog have a contact page? I’m having problems locating it but,
    I’d like to shoot you an e-mail. I’ve got some suggestions for
    your blog you might be interested in hearing. Either way, great
    blog and I look forward to seeing it expand over time.

  18. Reply big fish casino free chips May 3, 2014 11:43 am

    And if you’re not in the mood to brave the parking lot, Jimmy – C’s delivers via Dial and
    Dine. Just search “gourmet teas” or visit your local gourmet shop.
    Many gourmet coffee sites offer dozens of different coffees, including special
    blends for the Christmas season.

  19. Reply blackberry website May 1, 2014 10:09 am

    of course like your web-site but you have to test the spelling on several of your posts. Several of them are rife with spelling problems and I find it very bothersome to inform the reality on the other hand I will certainly come again again.

  20. Reply Aundrea Apr 30, 2014 11:55 pm

    Way cool! Some extremely valid points! I appreciate you writing this post and the rest of the website is extremely good.

  21. Reply Richard Arrow Apr 30, 2014 9:03 am

    Hi John,

    first of all,
    thank you for your very useful plugin!

    I implemented it mixing two of the solutions you’ve shown as:

    function manageDownloadWaitingPopup(event,form,waitingMessage,failureMessage){
    var $preparingFileModal = openWait(waitingMessage);
    $.fileDownload($(form).prop(‘action’),
    {
    successCallback: function(url) {
    $preparingFileModal.dialog(‘close’);
    },
    failCallback: function(responseHtml, url) {
    $preparingFileModal.dialog(‘close’);
    openAlert(failureMessage);
    },
    httpMethod: “POST”,
    data: $(form).serialize()
    });
    event.preventDefault(); //otherwise a normal form submit would occur
    }

    I had already some functions that I wanted to reuse (openWait and openAlert)
    This is the case of the openWait() method, which returns the id of the div used as dialog, and then this id is used in the successCallBack and failCallBack to close it.

    $(“form”).on(“submit”, function (e) {
    var action = $(this).attr(‘action’);
    if(action == ‘downloadTemplate’){
    manageDownloadWaitingPopup(e,this,’Downloading template…’,
    ‘There was an error in the process’);
    }
    });

    All this thing works fine on chrome, but in Explorer, if the download process goes wrong, the dialog doesn’t close. (When the download goes well, it cloes fine).

    Being suspicious, I tried the example from your page, the one with the action that uses the form,
    and when I put an odd number to make the download fail, the dialog does not close.

    It looks like there’s a problem on Explorer just when you use the:

    $.fileDownload($(this).prop(‘action’), {….

    Like it does not catch the failCallback…

    Any idea?

    • Reply Richard Arrow Apr 30, 2014 9:07 am

      But Actually It’s not because the failCallback.

      The example in your test page has:

      preparingMessageHtml: “We are preparing your report, please wait…”,
      failMessageHtml: “There was a problem generating your report, please try again.”,

      so it looks like the failure makes Explorer go mad… :S

      Any suggestion?

  22. Reply Audry Apr 29, 2014 7:37 am

    Magnificent goods from you, man. I have remember your
    stuff previous to and you’re simply extremely excellent.
    I really like what you have got here, certainly like what
    you are saying and the best way by which you say it. You’re making it enjoyable and you still care for to
    keep it sensible. I can’t wait to read far more from you.
    That is really a terrific site.

  23. Reply www.good.is Apr 9, 2014 2:39 am

    Jednak kwalifikacji obejmują podobny aplikacja nauczania i mają prosty status a poklask , wsio prowadzi aż do nazwy
    \” biegłego rewidenta \” ( ACA albo CA ) . Programów nauczania obejmuje przedmioty takie jak księgowość , audyt
    , biznes, finanse , podatki, prawa tudzież zarządzania przedsiębiorstwem , które są oceniane przede
    wszystkim za pomocą formalnych egzaminów . Zwolnienia z niektórych przedmiotów
    być może być możliwe w zależności od chwili instytutu
    , spośród zastrzeżeniem stopni studiował . Trasa będzie tak bywa zalecane
    z wykorzystaniem firmę szkoleniową . Jest także możliwe ICAEW zbadania bez względu w pierwszym
    etapie , nim rozpoczęciem egzaminu umowę szkolenia. Niezależnie
    od chwili wybranej trasy zostanie podjęta, dyscyplina naukowa gwoli
    tych egzaminów wymaga wysokiego poziomu zaangażowania a determinacji .
    Obok szkoleń test , pracodawcy zapewniają szkolenia w
    domu na umiejętności technicznych zaś ogólnych , które pomogą pracownicy wykonują przyzwoicie w theirjob .
    Biegli rewidenci muszą utrzymywać się na bieżąco w kwestiach technicznych zaś biznesowych
    , zatem istnieje mocny akcent na doskonalenie
    zawodowe po qualification.The większość biegłych rewidentów szkolić w praktyce publicznej
    oraz pierwsze danie trzy lata są poświęcone realizacji
    biegłego kwalifikacje. W tym czasie ich budowania doświadczenia a zanieść na
    siebie dodatkowe obowiązki , w tym monitoring pracowników niższego i w wyższym stopniu jawnie w kontakcie
    z klientami . Jest częstookazją do oddelegowania do innego obszaru praktyki w celu poszerzenia
    doświadczenia . Praktykanci na ogół pozostaje obok tego samego pracodawcy z wykorzystaniem zupełny contract.The szkolenia
    profesjonalny rachunkowości kwalifikacje stanowi podstawę do wielu tras aż do biznesu a potencjał rozwoju zawodowego są liczne i zróżnicowane
    po kwalifikacji . Pobyt w praktyce publicznych daje opcja oddelegowania
    bądź przeniesienia aż do różnych obszarów staż (np.
    corporate finance czy też doradcze w zakresie zarządzania
    ) bądź alternatywnieprzenieść aż do innej wielkości firmy.
    W dużych międzynarodowych firmach , są możliwe
    oddelegowanie zamorskie ( z reguły co dubel lata )
    . Progresja aż do partnerstwa jest konkurencyjny , aliści jest osiągalne odkąd ośmiu aż do 15 lat po kwalifikacji ( w małych firmach zaawansowanie może być szybsze ) .
    Zawodu księgowego w Wielkiej Brytanii prawdopodobnie stanowić cokolwiek mylące gwoli potencjalnych aplikantów , bowiem składa się z trzech innych organizacji zawodowych, nie zważając na trzech instytucji
    udzielających biegłego rewidenta kwalifikacji . Zazwyczajkwalifikacje następuje będzie być w zależności odkąd rodzaju organizacji łączony rodzaju rolę .
    Większość szkoleń w celu biegłych rewidentów są w pomieszczeniach practice.Public staż w
    zakresie od chwili firm jednoosobowych praktyków do dużych międzynarodowych firm i istnieją potencjał gwoli absolwentów szkolenia spośród firmy każdej wielkości , o
    tak dalece jest owo dozwolone za sprawą stosowny instytut .
    Oznacza to, iż uczestnicy mogą wyłowić preferowany środowiska pracy .
    Większe firmy ( w przypadku kiedy oferty są zagęszczone ) posiada biura w największych miastach w całym kraju .
    Mniejsze firmy mogą znajdować się skoncentrowane w określonym miejscu ewentualnie specjalizują się w
    konkretnym rodzaju typów client.Any związane z zatrudnienia ?
    Tak . Ta rejestr nie jest wyczerpująca , jakkolwiek oto parę
    podobnych i związane z nimi rodzaje roli : • Biegłych księgowego • Księgowy • Wyczarterowany administracja Biegły buchalter finansów publicznych • • sekretarka
    Zarządu Spółka inspektora doradca doradca • Podatki • Podatek , Inland Revenue.What
    magazynów handlowych bądź publikacji są dostępne gwoli tej
    branży Wszystkie poniższe magazynów oraz czasopism można
    nabywać odkąd każdej dobrej księgarni : Księgowość – Instytut Biegłych Księgowych w Anglii tudzież Walii ( ICAEW ) Accountancy Age – VNU firmy Publications.TARGET
    Miasto oraz Finanse – GTI Specjalista Wydawcy . . Finanse Casebook Hobsona – Praca Hobsons wydawnictwa PLC.Inside oprowadzacz
    Biegłych Rewidentów – . Cambridge Market Intelligence Ltd ( CMI )
    Gdzie mogę wyszperać więcej informacji Więcej informacji wolno wyszukać na stronie każdego spośród następujących
    organów oraz organizacji adresów zaś ich odpowiednie ?
    strony są :Stowarzyszenie Techników

  24. Reply typedia.com Apr 9, 2014 2:38 am

    W Pakistanie ,Instytut Biegłych Księgowych Pakistanu jest jedynym profesjonalnym oraz rachunkowość cielsko spośród prawem aż do udzieleniaChartered Accountant
    . ICAP jestczłonkiem IFAC ( Międzynarodową Federację Księgowych , IASB (
    Rada Międzynarodowych Standardów Rachunkowości ), Konfederacji Azji zaś Pacyfiku
    Księgowych ( CAPA ) zaś Południowej Azji Federacji Księgowych ( SAFA
    ) . Członkowie ICAP dotarły aż do 4089 od momentu marca .
    1 , dane wewnątrz rok kalendarzowy 2007 Rola zawodowych księgowych : Biura rachunkowe są niezależni doradcy firmy rachunkowe może zaoferować szeroką
    gamę usług księgowych może istnieć biegli rewidenci , wolno zestawić
    systemów księgowych klienta , być może
    byćdoradcą w zakresie planowania podatkowego , lubdetektor .
    . oszustw tudzież malwersacji , prawdopodobnie poczynić
    budżetowania natomiast analizy sprawozdań finansowych , doradza klientom w decyzjach finansowych ,
    dać możliwość specjalistyczną wiedzę natomiast przypadkiem odciążyć w
    utrzymaniu etyczne środowisko . Po omówieniu podstawowych
    pojęć a roli zawodowych księgowych jesteśmy w
    lepszej sytuacji , tak aby zastanowić się nad co zawodowe Etyka
    jest i w jakim celu jest to ważne w dziedzinie rachunkowości definicji etykisłowo \” filozofia moralności \” pochodzi od chwili starogreckiego
    ethikos słowa. ; Oznacza zwyczaje natomiast nawyki .
    Główną gałąź filozofii , która jestbadanie wartości a zwyczajów osoby bądź grupy tudzież
    obejmuje analizę zaś zatrudnienia pojęć takich kiedy dobro tudzież zło ,
    dobro oraz zło natomiast nakazów natomiast zakazów .
    Kodeks Etyki : W kontekście przyjętej dzięki kod komputerowy zawodu bądź organizacji rządowej , by wiadomy robota jest
    sterowany ,kodeks moralny być może istnieć
    tytułowana w charakterze kod odpowiedzialności
    zawodowej , który być może zaniechać spośród trudnymi problemami ,
    jakie zachowanie jest \” etyczne \” . Kodeks etyki jest częstoformalne
    oficjalna wypowiedź o wartości organizacji w pewnych kwestiach etycznych oraz społecznych dotyczących zawodu tudzież praktyki wiedzy zawodowej .

    Dotyczy owo oraz zasad zaś procedur określonych sytuacjach etycznych
    . Etyka w Professional Rachunkowości : Ogólne normy
    etyczne społeczeństwa stosuje się aż do osób w zawodach takich gdy : medycyna, przepis , pielęgniarstwa tudzież rachunkowym itp ,
    no tak samo podczas gdy do każdego innego .

    Jednak populacja stawia jeszcze wyższe oczekiwania
    na specjalistów . Ludzie muszą posiadać ufność aż do jakości kompleksowych usług świadczonych za sprawą specjalistów Etyka w rachunkowości zawodu są bezcenne gwoli specjalistów księgowych i
    do tych, którzy opierają się na ich usługi
    . Zainteresowane strony , w tym klientów, podmiotów udzielających
    kredytów , rządów, organów podatkowych , pracowników, inwestorów, przedsiębiorców natomiast społeczności finansowej itp postrzegają je
    gdy nadzwyczaj właściwe , rzetelne , obiektywne oraz neutralne osoby .
    Zawodowi księgowi muszą więc istnieć nie wprost przeciwnie porządnie
    wykwalifikowanych , jakkolwiek również posiadają szeroki stopień uczciwości zawodowej .
    Ze względu na te wysokie oczekiwania , specjaliści przyjęli przepis
    etyki ; modny oraz jak kodeksy etyki zawodowej .
    Te kodeksy etyczne wezwanie aż do ich członków , iżby nie oddać poziom samodyscypliny , które wykraczają
    niezależnie od wymogi przepisów ustawowych natomiast wykonawczych .
    Każdy z głównych stowarzyszenia zawodowego dla księgowych ma przepis etyki
    . Jak wspomniano już , zawodowi księgowi mogą egzystować dwojakiego rodzaju .
    Ktoś, kto pracuje w firmach ewentualnie bez względu wprawić w ruch te firmy , które zapewniają rachunkowości, audytu
    tudzież inne usługi doradcze w celu klientów ; nazywane są
    one praktyków public . Inni , którzy są pracownikami organizacji natomiast przypadkiem sprzyjać jak audytorów wewnętrznych ,
    księgowych , menedżerów finansowych zarządzających tudzież analityków
    finansowych . Niezależnie od chwili roli księgowych
    , są one przestrzegać kodeksu etyki , które mają używanie
    do ich działalności zawodowej , wszelako są pewne szczególne kodeks
    dla tych, w praktyce publicznej [ Źródła: Kodeks etyki zawodowych księgowych - Międzynarodowej Federacji Księgowych (IFAC) ] .
    Międzynarodowa Federacja Księgowych – IFAC :
    Międzynarodowa Federacja Księgowych (IFAC ) jest federacją wszystkich organów
    rachunkowości na całym świecie . Wszystkie najważniejsze międzynarodowe tudzież krajowe stowarzyszenia , takie
    gdy ACCA , AICPA , ICMA , ICAP , RMSR i tak dalej są jej organizacje członkowskie .
    Misją IFAC , kiedy określono w konstytucji
    , jest \”rozwój na całym świecie a amplifikacja o zawodzie księgowego ze zharmonizowanymi normami , w stanie być świadkiem usługi o niezmiennie wysokiej jakości w interesie publicznym \” [por. Kodeks etyki zawodowych księgowych - IFAC ] .
    Wypełniając owo obowiązek ,Rada ustanowiła IFAC
    Komisji Etyki IFAC wypracować natomiast zadenuncjować , na podstawie własnych,
    wysokiej jakości standardów etycznych i innych
    wypowiedziach dla zawodowych księgowych do użytku na całym świecie
    . Kodeks Etyki określa wymogi etyczne w celu zawodowych księgowych .
    Ciało fallus bądź firma nie przypadkiem stosować mniej
    rygorystyczne normy aniżeli te określone w niniejszym Kodeksie .
    Celem ustawienie tego przepis postępowania jest harmonizacja tych standardów natomiast pragmatyk w perspektywie globalnej
    . Publicznego przypadkiem zaufać na odwrót tych ogromnie specjalistów podczas gdy jest
    obowiązkowe , aby śledzić i badać prawo tudzież kodeksy na całym świecie

  25. Reply togakangaroo Mar 31, 2014 5:10 pm

    Years later I still love this plugin. One thing that I think is a *no* but I’m not certain – is it possible to do content negotiation with this?

    I have a route /some-report/render which will return either pdf or powerpoint depending on the submitted Accept header. Is that possible with this plugin? Is there any reliable way to trigger downloads where controlling your Accept header *is* possible?

  26. Reply togakangaroo Mar 31, 2014 5:09 pm

    Years later I still love this plugin. One thing that I think is a *no* but I’m not certain – is it possible to do content negotiation with this?

    I have a route /some-report/render which will return either pdf or powerpoint depending on the submitted Accept header. Is that possible with this plugin? Is there any reliable way to trigger downloads where it *is* possible?

  27. Reply free online shooting war games Mar 27, 2014 8:16 pm

    Appreciation to my father who shared with me about this webpage, this web site is
    truly awesome.

  28. Reply batman arkham city cheat codes for pc Mar 21, 2014 9:26 pm

    The grow taller 4 idiots testimonials as you can see, speak for themselves and there.

    Sweeney’s software is the fact that it provides a very user-friendly interface and there’s no need to be
    a pc gamer to make the best cover letter with this software.
    The Sony Play – Station Portable is an awesome
    gaming console ever since it was first released.

  29. Reply Emma Mar 18, 2014 12:01 pm

    How can i trigger the failCallback function? I’ve tried with error 500.

  30. Reply Narl Juns Mar 7, 2014 2:58 am

    Hey, I just noticed that occasionally this site shows a 500 error. I figured that you would like to know. All the best

  31. Reply Javier Feb 24, 2014 3:51 pm

    John

    I have implemented this in an asp.net project, it works with zip and pdf, but does not with txt files. ¿have you tested with this kind of files?

    thanks in advance

  32. Reply Mike E Feb 20, 2014 8:03 am

    I’ve implemented this in MVC using your FileDownloadAttribute and my own jquery. It works as expected/desired except that if you make the request multiple times, each subsequent request will result in multiple file dialogs appearing. The first time, one dialog appears. The second time, two dialogs appear. The third time, three appear. And so on. When I refresh the page, it reset this. Why would this be?

    • Reply Mike E Feb 20, 2014 8:10 am

      Doh. My fault. The click event was being bound multiple times to my button. I had to call unbind to make sure it was only bound once. Great tool!

  33. Reply anji Jan 30, 2014 11:01 pm

    Hi john.

    Thanks for the interesting post…

    can i get client saved path?

    kindly reply asap.

  34. Reply Irmie Jan 29, 2014 11:40 pm

    Is there a way to prompt the user with a “save as” dialog box & have the user specify the file name & path (rather than the file downloading to the default download folder with whatever default name)?

  35. Reply เต็นท์พับ Jan 29, 2014 11:43 am

    Hello, yup this article is genuinely good and I have learned
    lot of things from it concerning blogging. thanks.

  36. Reply Regan Jan 28, 2014 7:49 pm

    Hi John

    Please ignore my previous comment. The issue was with codeigniter. Its working!!!:)

  37. Reply Regan Jan 28, 2014 1:47 am

    Hi John

    I am using CodeIgniter. I can successfully use your plugin except when I enable secure cookies. This (secure cookies) is a requirement! Hence the plugin cannot determine the success of the download by reading fileDownload=true (it’s obviously encrypted in the cookie). Is there a way to send success via a different / special response header?? IF so, how would I modify the plugin to allow for that?

  38. Reply Richard Jan 25, 2014 11:37 pm

    In case anybody’s interested, I created a Ruby gem jquery_file_download-rails to integrate this script into the Rails asset pipeline.

  39. Reply Avi Jan 19, 2014 12:53 am

    Hi John,

    First of all, great Plugin, and Excellent post!

    Can I use it without MVC callback? but ordinary asp.net button onclick event?
    I means,
    I have asp.net button with OnClick event that on postback to server side I’m loading the file data from DB.

    I want $.fileDownload to access my btnDownloadFiles_Click(object sender, EventArgs e) event and download my dynamic load file.
    I allready have implemented btnDownloadFiles_Click with Response.Write(fileData);
    All I need is how to combite $.fileDownload with btnDownloadFiles_Click event?

    Avi.

  40. Reply Annette Jan 18, 2014 6:37 pm

    It is, however, feasible for an expert to crack these regular encryption methods.
    It runs very smoothly and quietly from the background of the Mac.
    Taking a cue from that, if publishers may make their ebooks open to a larger audience instantly, it could and will encourage readers to go for that authentic version.

  41. Reply Philipp Jan 13, 2014 8:37 am

    This page does not load in Firefox 26.

  42. Reply import documentation Jan 3, 2014 5:02 pm

    Excellent way of explaining, and good post to get
    facts concerning my presentation topic, which i am going to present in academy.

  43. Reply Mukul Garg Dec 30, 2013 1:30 am

    Hi,

    I have tried with plugin with iPad. But this does not work on iPad as the URL to file download is actually a ASP.NET Handler instead of normal HTML document due to which “downloadWindow.document is undefined” error is coming.

    Please provide the updates for Handler pages.

    Thanks

  44. Reply Benjamin Granados Dec 20, 2013 6:41 am

    Hi!

    Thanks for the plugin!

    I’m having issues with safari downloading pdf’s. They stay opened at the hidden iFrame, don’t know why!. I used the headers, but if I force the download (example: Content-Type: application/force-download), It downloads the php page, not the pdf document!!! When I look for the hidden iFrame, it has the following headers: Content-Type: application/pdf. I imagine that Safari just opens the pdf instead of downloading it!. With other file types it works great and Firefox saves my pdf’s just as expected.

  45. Reply Ivi Nov 27, 2013 9:11 am

    Well thanks, that is great. i was trying to accomplish something similar but i stepped into this solution and it was all i needed.

  46. Reply Mayank Ag Nov 20, 2013 7:52 pm

    Hi,

    I’m using this plug-in on my webpage. Let’s say my webpage is at A.com, but the file I’m downloading is at B.com. Problem arises only in IE where it does not see the cookie returned by B.com. It treats it as a third-party cookie or god knows what. Tried changing IE privacy settings to allow third-party cookies but it still does not work.

    Any clues on how to get around this?

  47. Reply Gene Raymer Nov 12, 2013 9:07 am

    John,

    This plugin looks very cool. I see from the download you are making it beginner friendly too. The one thing missing is a license statement. I assume you are doing something like MIT / GPL dual licensing? If you throw a license file in there it will make us corporate types more comfortable.

    Thanks

  48. Reply swetha Oct 28, 2013 1:15 am

    HI..,

    I am using this javascript for blackberry app, but it is not working in blackberry v5,v6 & v7. It is not showing any prompt for the users to download the file.

  49. Reply Supaiku Oct 10, 2013 12:44 pm

    Have anyone gotten this done in PHP or webforms? The guide isn’t super beginner-friendly, I’d like a simple example, just to know the general setup with the headers and the iframe and so on. If anyone could be helpful, that’d be great.

  50. Reply Oct 2, 2013 4:49 pm

    Hi John

    In IE8, when I tried to download by second time, the page was blank.
    My site is developed in asp.net.
    Can you help me?

    thanks,

  51. Reply David Madden Sep 18, 2013 7:07 am

    I am trying to use this functionality from a button on a modal dialog so that they can view a PDF form to confirm the data on the modal dialog. It refuses to open the file although I have it referencing a link on the same page the dialog reads itself from. Any ideas about this condition?

  52. Reply alvin Sep 11, 2013 12:26 am

    Sir this article is verry helpfull base on the article u wrote but Sir may i ask if u have version for 2010 visual studio our company is know developing using 2010vs so i cant view the project

    thanks..

  53. Reply Dan Sep 4, 2013 7:49 am

    Works great with twitter bootstrap modals as well!

  54. Reply Klaus Aug 21, 2013 8:51 am

    I put the line:
    document.cookie = settings.cookieName + "=true; path=" + settings.cookiePath;

    at the end in the onPrepare-function.

    By that I did not need to have it set by code.

  55. Reply obsługa techniczna konferencji Aug 6, 2013 6:58 am

    Oh my goodness! Incredible article dude! Many thanks, However I am having problems with
    your RSS. I don’t understand the reason why I can’t subscribe to it.

    Is there anybody else having identical RSS
    problems? Anybody who knows the solution can you kindly respond?

    Thanks!!

  56. Reply hotel Aug 3, 2013 6:39 pm

    Hello to every one, it’s truly a pleasant for me to go to see this web site, it contains useful Information.

  57. Reply Click here to visit this page! Jul 20, 2013 12:23 pm

    Thanks a lot for sharing this with all people you actually know what you are
    talking about! Bookmarked. Please also consult with my web site =).
    We could have a link trade contract between us

  58. Reply sleeping tablets Jul 17, 2013 8:55 am

    Spot on with this write-up, I actually think this website needs a great
    deal more attention. I’ll probably be back again to read through more, thanks for the information!

  59. Reply lose weight Jul 17, 2013 6:08 am

    I’m truly enjoying the design and layout of your website. It’s a very easy on the eyes which makes it much more enjoyable for
    me to come here and visit more often. Did you hire out a developer to create your theme?
    Fantastic work!

  60. Reply Giulia Jul 12, 2013 7:23 am

    just a note: required jquery version is 1.6 not 1.3
    prop() used to create the iframe, was intoduced with 1.6 =^_^=

  61. Reply Kobus Jul 10, 2013 8:58 am

    Thanks! Saved me a few hours doing it myself… Haha! Who am i kidding… This plugin ROCKS! Tried to implement an iframe/AJAX based download solution myself after i did a simple upload one, but got bitten… You rock thanks John!! Saved me a LOT of time and headaches!

  62. Reply thetom Jul 9, 2013 3:48 am

    Hello and thank you for your plugin.
    I have a question: what if the client browser doesn’t accept cookies? What happens?

  63. Reply Daniel Jun 20, 2013 10:27 am

    Great plugin!!! But it looks that I’m in the IE hell…It always triggers the failCallback with IE even when the report downploads successfully!!!! no problem with other browsers. Somebody had this before?

  64. Reply Alex Jun 11, 2013 12:13 am

    Looks quite cool, but if the cookie is just named “fileDownload” than doesnt that mean that it can only manage a single download file at a time?

    In my case I am triggering the download of multiple large images. Once the first one is done all the others will think they are done as well..

    Would it not be better for each instance to have its own unique cookie name to test?

  65. Reply melih Jun 7, 2013 3:32 am

    Could you please tell How we can set the responseHtml(used in fail callabck) from server, from where we are getting this value

    • Reply John Culviner Jun 15, 2013 7:10 pm

      It doesn’t necessarily work in some versions of IE. Basically it just takes the error HTML from your response and stuffs it into the failCallback variable.

  66. Reply Dr.Gonzo May 28, 2013 10:30 am

    Hi John, good job, I have this problem: I have to distinguish the session expired error from the other possible errors, in the first case the server sends back a 401 status code, but from what I understood the only thing I can have in the failCallback is the html and not the http status codes, am I right?

    • Reply John Culviner Jun 15, 2013 7:13 pm

      There isn’t any way to do this with the plugin. If I were you I would just hit an ‘empty’ endpoint on the server with AJAX before you call jquery file download and see if you get the expected response back. If you do then call jquery file download

  67. Reply Pierpaolo May 24, 2013 9:33 am

    Hi, nice work!!

    I’m experiencing a problem with IE8, complaining about security (Internet Explorer Information Bar): “internet explorer blocked this site from downloading…”.

    Is there a fix for this? I mean, a code fix, because changing the security options of Internet Explorer is not a possibility: I cannot tell all my users to do so…

    Thanks in advance
    Cheers

    Pierpaolo

  68. Reply Michael May 24, 2013 6:11 am

    Hey John,
    I have some trouble with your JS. I get the message from the IE Debugger, that a method or property with the name fileDownload not exists. I have these three References.
    script src=”Scripts/jquery-1.9.1.min.js” type=text/javascript”
    script src=”Scripts/jquery-ui-1.10.2.custom.min.js” type=text/javascript”
    script src=”Scripts/jQueryFileDownloadPluginv1.4.0.js” type=text/javascript”
    Do you have some tips.
    Regards Michael

  69. Reply BC May 23, 2013 11:28 am

    I am working on implementing this wondeful solution but am having a problem with the jquery Dialog creation.

    I have the following Javascript includes:

    Any reason whey it crashes on this line in fileDownload.js:

    $preparingDialog = $(“”).html(settings.preparingMessageHtml).dialog(settings.dialogOptions);

    It would appear that something is amiss with the jquery dialog but the Javascript files are being correctly referenced…

    Thoughts?

    TIA!

    • Reply BC May 23, 2013 11:31 am

      oops forgot to remove the html formatting so the references for the JS files would show up, so…

      script src=”/Scripts/jquery-1.8.3.min.js” type=”text/javascript”
      script src=”/Scripts/jquery-ui-1.8.20.min.js” type=”text/javacript”
      script src=”/Scripts/jquery.fileDownload.js” type=”text/javascript”

      • Reply BC May 23, 2013 1:57 pm

        weird apparently this jquery plugin doesnt work with jquery 1.8.3, only with 1.9+ FWIW

        • Reply John Culviner May 23, 2013 8:23 pm

          Hi BC,

          Thanks for the feedback. I looked into it and I’m having no problems with 1.8.3 in Chrome. I have a feeling there might have been something else going on as well. Thanks for letting me know though!

  70. Reply Jérôme Ducobu May 16, 2013 9:18 am

    Could you create and publish a nuget package for the visual studio developer ?

    • Reply John Culviner May 16, 2013 9:49 am

      Excellent idea! I’ll see if I can get this done soon…

      • Reply Ashok Feb 14, 2014 4:47 pm

        Hi John,
        You mentioned you will try to get the request headers done soon. Did you get a chance?

        I’m looking to add some custom request headers to my download request.

        This is need for security.

        Thanks,
        Ashok.

        • Reply John Culviner Feb 16, 2014 10:52 pm

          Hi Folks,

          Unfortunately there isn’t any way to do custom headers with an IFRAME (which is the only way to do this currently). An IFRAME must be a get request but you could of course set custom cookies (which are headers) with JavaScript before you make the request. Thoughts?

  71. Reply Scott Wells Apr 11, 2013 10:15 am

    Is it possible to add request headers to the download request or does everything have to be in the URL as query string parameters? Since this is basically driving an IFRAME, my suspicion is that it's not possible to augment the request in this manner, but it certainly doesn't hurt to ask!

    • Reply Ashok Feb 14, 2014 4:48 pm

      Hi John,
      You mentioned you will try to get the request headers done soon. Did you get a chance?

      I’m looking to add some custom request headers to my download request.

      This is need for security.

      Thanks,
      Ashok.

      • Reply John Culviner Feb 16, 2014 10:52 pm

        Hi Folks,

        Unfortunately there isn’t any way to do custom headers with an IFRAME (which is the only way to do this currently). An IFRAME must be a get request but you could of course set custom cookies (which are headers) with JavaScript before you make the request. Thoughts?

  72. Reply Chandra Mar 28, 2013 7:51 am

    Hi All,

    Download processing is fine but after downloading the file dialog is not closing.I have read the comments and i have come to know the problem is that need to add setCookie method but where i have to place this bit of code. i haven't get an idea.Now am working on Spring MVC so could any one please help me ASAP.I will be greatly if help. Thank you in advance.

  73. Reply Vivek Mar 6, 2013 2:27 am

    Could you please tell How we can set the responseHtml(used in fail callabck) from server, from where we are getting this value

  74. Reply Sachin Srivastava Mar 1, 2013 2:40 pm

    Hi John

    I am trying to use the plugin for a DotNetNuke site, I need to allow user to download a PDF which is already created at path somewhere at website/desktopmodules/download/file/path/of/file.pdf but at line 370 of plugin it is saying "Permission denied to access property 'body'" …what is this…i am stuck on this feature and need it urgently as it is really a great plugin to use. jquery code i have used is as below :
    $.fileDownload(r.d, { preparingMessageHtml: "We are preparing your report, please wait…",
    failCallback: function(html, url) {
    alert('Your file download just failed for this URL:' + url + '\r\n' +
    'Here was the resulting error HTML: \r\n' + html);
    }
    });
    Where r.d is a nested path to pdf. Please suggest on what step I am wrong. Thanks for the plugin :)

  75. Reply Federico Debetto Feb 26, 2013 12:11 pm

    I have a problem retrieving files address with folder.
    For instance, ./invoice/invocie_1.pdf became ._invoice_invocie_1.pdf
    anyone knows why ?
    Thx
    - Kiko -

  76. Reply Simone Feb 26, 2013 5:07 am

    Hi,
    first of all thanx for this plugin, which is very useful indeed…
    I'm having though an issue when downloading a pdf on iPad in full screen mode.

    Doing a little research on google, it turns out that window.open on a full screen web app doesn't work,
    and should be substituted with the normal href action of the link.

    Is there a way to get this plugin working for an iOS web app working in full screen mode?

    Thanks,
    Simone

  77. Reply Richard Feb 21, 2013 3:50 pm

    Hi

    Great plugin! I do have a question though: I want to perform various other ajax operations while the download is in progress (my downloaded file takes a while to create on the server). On the server I keep track of how much progress the 'file building' has made. After my call to $.fileDownload(…) I want to regularly call another ajax.get method which will let me update a progress bar with accurate values.

    At the moment (unless I've configured it wrong), any ajax calls I make after $.fileDownload(…) are queued up and only get executed after the file download has completed. I've even tried adding a $.get(…) call inside the 'checkFileDownloadComplete' function, but it still gets queued.

    Is there any way to achieve this functionality?

    Thanks!

  78. Reply Jason Cosman Feb 18, 2013 8:28 pm

    Hello;

    Great plugin this is amazing! I do have a question although I think I know the answer I thought I'd ask anyways. In your example using MVC you return the value of FilePathResult to the method. Is it possible to use the HttpResponseMessage and actually return a file that's in memory? The case I have is that I'm generating the file on the fly and trying to download it using your amazing plugin. Any help would be great! Thank you very much.

    • Reply Lisa May 20, 2013 3:14 pm

      Hello!

      I am trying to do the same thing as Jason. Is there a way to download a file that exists only in memory?

  79. Reply william Feb 12, 2013 2:55 pm

    Thanks for the plugin! I'm able to get it working on all browsers. But in iOS, if popup is enabled, I can not get the new tab to load. Any way to bypass that?

  80. Reply Bart Lewis Jan 17, 2013 4:04 pm

    Great plugin, John! I had some problems getting successCallback to fire, but found the problem after a little while. You can save future PHPers a little confusion if you change your PHP example as follows:

    header('Set-Cookie: fileDownload=true'); // no workie

    to

    header('Set-Cookie: fileDownload=true; path=/'); // no workie

  81. Reply Girish Ramarao Jan 17, 2013 11:54 am

    Hi John,
    First of all thank you for the wonderful script. Saved a lot of time in exporting the file to Microsoft Excel and download the same from the server.
    Though I could force download the file which was opening the file dialog, I was looking at an option where the download success message was displayed on the user screen. You script help me do it. I did have a small glitch in the code. In your example for PHP you have set the cookie name to be 'fileDownload' and its value to 'true'. For some reason the condition where the cookies are checked for equality failed (ver 1.3.3 line # 304). So I got the PHPSESSID cookie value and set the same for the options in the script. Now the onSuccess call back got a hit. But unfortunately, the cookie was being removed and this used to expire my session. I commented out the cookie removal code and its working fine. I am yet to test further to see if there is any issues in commenting out the code in your script. Looking forward to your suggestions and any corrections to the approach I adopted.

    Thanks,
    Girish

  82. Reply Girish Ramarao Jan 17, 2013 8:30 am

    Hi John,
    First of all thank you for the wonderful script. Saved a lot of time in exporting the file to Microsoft Excel and download the same from the server.
    Though I could force download the file which was opening the file dialog, I was looking at an option where the download success message was displayed on the user screen. You script help me do it. I did have a small glitch in the code. In your example for PHP you have set the cookie name to be 'fileDownload' and its value to 'true'. For some reason the condition where the cookies are checked for equality failed (ver 1.3.3 line # 304). So I got the PHPSESSID cookie value and set the same for the options in the script. Now the onSuccess call back got a hit. But unfortunately, the cookie was being removed and this used to expire my session. I commented out the cookie removal code and its working fine. I am yet to test further to see if there is any issues in commenting out the code in your script. Looking forward to your suggestions and any corrections to the approach I adopted.

    Thanks,
    Girish

  83. Reply Shreyas Hinduja Jan 12, 2013 12:09 am

    I have problem integrating the code with VB.net can somebody help with a demo code in vb.net.

  84. Reply Shreyas Jan 11, 2013 7:48 am

    I implemented the code in vb.net but it does not work.No error in show but it just does not download.

    code used in server side
    HttpContext.Current.Response.SetCookie(New HttpCookie("fileDownload", "true") With { _
    .Path = "/" _
    })
    ——————————————————-
    Javascript to fire on onclick

    function downfile()
    {
    try
    {
    //alert("entred");
    var linkHref = "http://anywebsite.com/images/1.jpg&quot;;
    $.fileDownload(linkHref);
    }
    catch(e)
    {

    }
    }

    Can any body guide me with this.

  85. Reply Andrus Jan 5, 2013 12:58 pm

    This plugin does not work if Content-Disposition: inline; is returned. pdf file is not opened in new tab. Nothing happens. How to open pdf file in new tab using this?

  86. Reply gianni Nov 10, 2012 8:10 pm

    Hi John,

    great plugin, and indeed very useful.

    Tested v1.3.3 on OSX 10.7.5 – FF 16.0.2 and Safari 6.0.1.

    I tried to throw an error response for the form example (in my case, the php file echoes some html as a warning for no data to be downloaded):
    - OK in FF
    - in Safari it looks like the try/catch part in checkFileDownloadComplete() (line #318) is never reached, being always intercepted by the preceding check for cookie existence (line #302).

    Switching the order of the two statements everything works fine.

    Is it me or anybody else had the same behavior?

    Thanks, Gianni

  87. Reply Barbara Post Oct 16, 2012 5:06 am

    Hi John,

    Using version 1.3.3 I noticed the following browsers behaviors : IE9 (9.0.8112.16421) and Safari 5.1.7 don't properly handle the file download when http method is POST (I need to use POST rather than GET because I may send a lot of data from page): file downloads but there is no prompt for user to do something with file data (save, open…). I searched on the internet and send you a diff file (I don't have a github account, sorry) for the following changes : add a name for iframe, target form to it. For both browsers I quoted above, rather set target to _blank.
    I saw that non-hidden iframe will show a PDF document (the only kind of file I tested) for IE9 if targeting form to it. But its default size is unpractical. For browsers which prompt user, non-hidden frame border is visible, and it just blinks on file download, right before prompt displays.

    Finally I wonder whether I've found something specific to PDF files, related to PDF preview in browser plugin being installed ? Thank you for your feeback about this and the patch I propose.

    Thank you for this great plugin,

    — eaa_jquery.fileDownload-1_3_3.js 2012-10-15 10:33:31.711876000 +0200
    +++ eaa_jquery.fileDownload.js 2012-10-16 11:37:09.265816700 +0200
    @@ -115,8 +115,12 @@
    var isIos = false; //has full support of features in iOS 4.0+, uses a new window to accomplish this.
    var isAndroid = false; //has full support of GET features in 4.0+ by using a new window. POST will resort to a POST on the current window.
    var isOtherMobileBrowser = false; //there is no way to reliably guess here so all other mobile devices will GET and POST to the current window.
    + var isTargetNewWindows = false; //there are browsers like some versions of IE9, Safari 5, which don't open user prompt after file download with POST method to iframe, so use blank target.

    - if (/ip(ad|hone|od)/.test(userAgent)) {
    + if (userAgent.indexOf('trident/5.0') != -1 || userAgent.indexOf('safari/') != -1) {
    + isTargetNewWindows = true;
    + }
    + else if (/ip(ad|hone|od)/.test(userAgent)) {

    isIos = true;

    @@ -127,7 +131,6 @@
    } else {

    isOtherMobileBrowser = /avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|playbook|silk|iemobile|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4));
    -
    }

    var httpMethodUpper = settings.httpMethod.toUpperCase();
    @@ -270,32 +273,28 @@
    .html(formInnerHtml);

    } else {
    -
    + // POST method
    if (isIos) {

    downloadWindow = window.open("about:blank");
    downloadWindow.document.title = settings.popupWindowTitle;
    formDoc = downloadWindow.document;
    window.focus();
    -
    } else {
    -
    - $iframe = $("<iframe style='display: none' src='about:blank'></iframe>").appendTo("body");
    + $iframe = $("<iframe style='display: none' src='about:blank' name='my_iframe'></iframe>").appendTo("body");
    formDoc = getiframeDocument($iframe);
    }
    -
    - formDoc.write("<html><head></head><body><form method='" + settings.httpMethod + "' action='" + fileUrl + "'>" + formInnerHtml + "</form>" + settings.popupWindowTitle + "</body></html>");
    + var myTarget = isTargetNewWindows ? "_blank" : 'my_iframe';
    + formDoc.write("<html><head></head><body><form method='" + settings.httpMethod + "' action='" + fileUrl + "' target='" + myTarget + "'>" + formInnerHtml + "</form>" + settings.popupWindowTitle + "</body></html>");
    $form = $(formDoc).find('form');
    }

    $form.submit();
    }

    -
    //check if the file download has completed every checkInterval ms
    setTimeout(checkFileDownloadComplete, settings.checkInterval);

    -
    function checkFileDownloadComplete() {

    //has the cookie been written due to a file download occuring?
    @@ -375,7 +374,7 @@

    function cleanUp(isFailure) {

    - setTimeout(function() {
    + setTimeout(function () {

    if (downloadWindow) {

  88. Reply harsh Oct 11, 2012 2:11 pm

    Can this plugin send json data via post, to the server?

  89. Reply Dave Oct 3, 2012 1:36 pm

    I'm having problems setting the cookie from a WebAPI controller. Anyone have an idea on how to accomplish this?

  90. Reply John Oct 2, 2012 11:43 pm

    @Sumadartson

    Glad the plugin is working for you. That's a great idea to include the promise/deferred interface. Perhaps I can include that in a future commit. Feel free to contribute on GitHub in the mean time if I don't get to it for awhile. Thanks!

  91. Reply Sumadartson Oct 2, 2012 3:39 am

    Hello John,

    Looks really nice! I've been looking for a pluging like this for a while.

    Anyway, short question. Are there any plans to have the filedownload function return an appropriate promise/deferred object? I checked the source code, but couldn't find anything.

  92. Reply John Culviner Sep 25, 2012 9:23 am

    @Bill Hudspeth

    I would try stepping through the jQueryFileDownload source and see why the callback isn't getting called. I don't think it's an issue with the code since it appears to be working in the demo but you never know. If I were to throw a guess out there I would think that perhaps the cookie is being written incorrectly. For example are you writing for path=/?

  93. Reply Bill Hudspeth Sep 24, 2012 11:28 am

    Hello John,

    I am having a few problems using the code from your "Custom rich user experience – jquery.fileDownload.js & jQuery UI Dialog". The modal dialog opens and the file download completes, but the dialog box does not close. It is not clear that the successCallBack function is ever called. The response header for the downloaded file has the appropriate settings for the cookie, as you describe in the documentation, so I'm not sure what might be broken. Also, the text "We are preparing your report, please wait…" never appears in the dialog. This behavior is true for both Firefox 15.0.1 and Chrome.

    Thanks, Bill

  94. Reply Bill Hudspeth Sep 24, 2012 10:52 am

    Hello John,

    I am having problems with getting the dialog to close. Files are successfully downloaded, but the dialog remains open after the download. I am using the code snippet from your "Custom rich user experience" that employs the 'preparing-file-modal' divs. The cookie is correctly returned in the response header, so I don't believe that is the problem. Also, the text in the dialog "We are preparing your report, please wait…." does not appear. This problem occurs in both Firefox 15.0.1 and Chrome. Any clues on what I should be checking would be appreciated.

    Thanks much, Bill

  95. Reply Richard Sep 20, 2012 12:44 pm

    John, I managed after all. I can recognize empty download on server side, so I sent the same cookie but with different value. Then I copied your check of a cookie and callbacks and made emptyCallback available. It is pleasure to work with your jQuery plugin and it was easy to adapt it – even for JS/jQuery newbie like I am. :-) Now I have success, empty download and error as three different paths with three different feedbacks for user. Thank you again very much.

  96. Reply John Sep 19, 2012 10:30 pm

    @Richard:

    Thanks for the feedback. I have noticed things getting hairy with IE due to the "stock" pages that it presents with certain >= 500 HTTP Response codes. I'm not aware of any way around it at this point unfortunately.

  97. Reply Richard Sep 19, 2012 2:30 am

    Very interesting plugin and it works for me except for IE7. Trouble in my case is, that the download may be empty, in which case failCallback is used. In IE7, however, this is not enough. After a lot of trial/errors I managed to copy your examples completely and found out that with error code 500 for empty response it works OK in all my browsers.

    But the question is – is there any other way how to treat empty download differently? What if real error occured on the server – then I can't distinguish it from empty response (which I have to mask as 500). I originally tried 404, which was probably deep misunderstanding on my part – this rather refreshed the whole page in the browser.

    I'd welcome any suggestions as I'd love to use this plugin in our future works, it seems quite reliable when I stick to 500 code for errors :-) and the experience is just great. Users just can't be talked out of wanting to disable buttons and then enable them again, so we have to use something like this.

  98. Reply John Sep 17, 2012 10:17 pm

    @Ronnie

    Interesting, thanks for bringing this up.

    Fix one bug cause another, welcome to software development eh?

    Any ideas what might be causing this?

  99. Reply Ronnie Andreasen Sep 11, 2012 6:05 am

    Hi John

    After you've added "var $ = jQuery.noConflict();" to the script and after I implemented System.Web.Optimization for bundling and minification in MVC4, the script will no longer work in IE8.

    The error "'$' is null or not an object" is thrown and then of course numerous "object expected" errors.

    If I remove uncomment that line, everything loads fine. The line causes no problem in other webbrowsers, that I have tested with (IE9, IE10, Firefox, Chrome).

  100. Reply Ravish Mishra Sep 7, 2012 3:03 am

    Thanks. This plugin saved a lot of time.

  101. Reply Andrew Laws Sep 6, 2012 10:35 pm

    Cheers for that John!

    As far as I can tell, your changes have fixed the problem.

  102. Reply John Culviner Sep 6, 2012 10:20 pm

    Hi Everyone,

    Thanks for the heads up on the Firefox issue and the solution Andrew Laws/Mark. I have updated the GitHub and the demo site with a setTimeout 0 around the cleanup which should clear the stack before cleaning up hopefully fixing the issue. I'm unable to get it to happen now. Anyone please let me know if you can get it to happen again, thanks!

    John

  103. Reply jboffel Sep 4, 2012 9:48 am

    I confirm that for firefox there is problem. It'll fail silently and randomly even on demo for success case.

  104. Reply Jamie Aug 31, 2012 1:53 pm

    I have an odd dilemma. This is using Firefox 15.0 (release).

    If I do not add the SetCookie to the header, my callbacks are called too early.

    If I DO add the SetCookie to the header, it may be 2 or 3 clicks before I see the dialog asking whether I want to open or save the file, but the file save dialog never appears after I click "Ok" on that one. However, the callbacks don't get called until that dialog goes away, which is what I'd expect.

    Any ideas?

  105. Reply Riddhi Bhavsar Aug 27, 2012 8:28 am

    I need to use this plugin with coldfusion 9. Here I found demo with ASP.NET & PHP. I want to use this with coldfusion. No idea how to manage code related to cookie as shown for ASP.NET. Any idea?!

  106. Reply Mark Aug 16, 2012 4:52 pm

    This is in response to Andrew Laws and anyone else experiencing intermittent failures to get prompted to save a file. The problem appears to be due to the iframe getting removed too quickly. I solved the problem by changing line 369 of v1.3.0:

    setTimeout($iframe.remove, 1000);

    The added delay seems to clear up the problem. A better solution might be to check and see if the iframe already exist when it is being created and if so, remove the existing one first.

  107. Reply Lakpak Sher Aug 13, 2012 8:29 pm

    [HttpPost]
    public FilePathResult DownloadReportPost(int foo)
    {
    //How do we get values from the entire page here

    string s = "are you getting page contents here?";

    return GetReport(foo);
    }

    In the above, how do I get all values on the form on client (HTML page)?? thanks.

    Lakpak Sher

  108. Reply Jim Jul 31, 2012 12:52 pm

    If you are using .Net, beware of the <httpCookies httpOnlyCookies="true" requireSSL="false" /> setting. If you have httpOnlyCookies on you won't be able to read the cookie client side and it won't work. I think this might even be the default option.

  109. Reply Rubens Jul 24, 2012 2:27 pm

    Hi John,
    Your lib accepts a array in [b]'data'[/b] parameters?
    Example:
    A checklist sends a lot of params with the same name, so the server is waiting a list like object.

    Thanks! Great work!

  110. Reply adam Jul 20, 2012 4:00 pm

    ..and here i am again. upon further debugging, i understand the issue here. since i'm making two requests, first to my app server for the generated s3 url, second to s3 using that generated url, the iframe disappears. here's why:

    on the first call to the app server, set-cookie downloadFile=true happens, which checkFileDownloadComplete sees and kills the iframe before it can start downloading from s3.

    but you can't set cookies from s3, so is there a solution here? i'm new to javascript and jquery so i'm not sure. if i don't ever set that cookie, i can use the basic functionality of this plugin, but i would like to use the advanced functionality if i can.

  111. Reply adam Jul 20, 2012 1:31 pm

    i forgot to add that the download does succeed, the onSuccess callback happens and watching traffic in my http proxy i see that the file does get transferred. the problem is that no file dialog appears to save as, nor does the file download appear in the downloads section of the browser, it seems to just get loaded into the current document invisibly.

  112. Reply adam Jul 20, 2012 12:25 pm

    hey john, thanks so much for jQuery filedownload, it's great.

    i'm stuck on a problem with it and hope you can help, wasn't sure if a message or a post would be better.

    my files are stored in s3 buckets.

    - i generate the s3 auth url on my app server and then pass that url to $.fileDownload().
    - app server sets the cookie fileDownload=true when it returns that generated s3 url
    - i have s3 returning the correct content-disposition: attachment header to force download.

    but no file download is initiated.

    if i hit that s3 generated link in a new tab, it downloads correctly. if i try $.fileDownload() on a file that is served directly from my app server (where i set-cookie fileDownload=true) the download is initiated correctly.

    i can't set-cookie from the amazon s3 server. does that mean i'm out of luck? or is there another way to approach this? does the set-cookie header have to happen in the same response that serves the file

  113. Reply Juan Alejandro Zapeta Perez Jul 17, 2012 3:12 pm

    Good plugin, i have a question.
    its avaible without jqueryUI???

  114. Reply Jose Jul 11, 2012 4:42 am

    Hello John.

    This tool is really useful. I have it working but it would seem that it doesn't work for ALL extensions of files. At least that's my conclusion after trying to download 5 files with the same name but different extensions. Some were downloaded but to the others appeared the "A file downloaded error …" box and didn't download. And it's happening a funny thing in IE. When I request the download, the save box shows up but also the error box (when downloading known extensions).

    Apart form that, nice work!

  115. Reply Andrew Laws Jul 9, 2012 1:12 am

    Howdy,

    Just wondering if anyone else has noticed an intermittent failure with this plugin when using Firefox? This is with a "straight" out of the box Firefox install (v13.0.1, in case anyone is interested), and no extensions added.

    I'm seeing this *only* on Firefox. Chrome, Opera, Safari and, yes, even IE(!) work just fine.

    It's easily reproducible for me on the demo page (http://jqueryfiledownload.apphb.com/). 1 in about every 8 clicks on the top "Report0.pdf" will fail silently – that is, the "We are preparing your report, please wait…" dialog disappears but no file save download dialog appears. There is absolutely no indication that anything has gone wrong apart form this.

    When the failure occurs, it's not permanent, and clicking on the link again usually gets me the file (but it still fails intermittently afterwards).

    I've tried to figure out what's going on by installing the FireBug extension and debugging, but I can't track down the difference between the successes and failures. The flow of execution seems the same in both cases. Having said that, I have noticed that:

    a) the presence of the FireBug add-on *seems* to increase the number of failures
    b) if I remove the call to kick off the checkFileDownloadComplete on line 286 of v1.3.0, the problem *seems* to go away (but then, of course, the success/fail callbacks never happen)
    c) similar to (b), if I increase the checkInterval beyond the length of time the file takes to prepare on the back end, the problem seems to go away. For example, if my test file takes 5 seconds to prepare, and I set the checkInterval to 10000 (i.e., 10 seconds), then all is good.

    b) and c) indicate a problem with the checkFileDownloadComplete() method, but it all looks very innocent to me.

    Also, it could just be that I have been lucky and not seen it under those conditions – the usual problem with the intermittent problems…

    It'd be useful to know if anyone else has noticed this issue!

    Apart from this, the plugin is very clever and most awesome – great work!

    Cheers!

    Andrew

  116. Reply John Culviner Jul 5, 2012 9:13 am

    Hi Stumblor,

    Good idea on checking the iframe's readyState. Your right though, unfortunately when I was testing this approach Chrome didn't work. Each browser that did work had different things happen to the readyState (of course right?) but at least it changed, Chrome's simply wasn't affected at all. Thanks for the thought!

    John

  117. Reply Soul Jul 5, 2012 5:10 am

    My successCallback is never called because
    if (document.cookie.indexOf(settings.cookieName + "=" + settings.cookieValue) != -1)
    is always false

    On the server side I added
    header('Set-Cookie: fileDownload=true');
    into my PHP with other headers
    I also looked up wireshark and I am sure the Set-Cookie is in the header

    Somehow my browser does not write Set-Cookie in to browser's cookie

    Any idea?

    Thanks~

  118. Reply Stumblor Jul 5, 2012 3:34 am

    Nice, I like it. Provided a solution to a large file download problem I was having.

    I can't help but think though, is the cookie component even necessary? The iframe state can be tested using .readyState, ie:

    if (formDoc.readyState == "complete") {
    //execute specified callback
    internalCallbacks.onSuccess(fileUrl);
    cleanUp();

    see the below article:
    http://stackoverflow.com/questions/6183737/dynamically-create-an-iframe-and-attach-onload-event-to-it

    Am I missing something here? Cross browser compatibility perhaps?

  119. Reply John Jul 1, 2012 10:04 pm

    Thanks Jared, I'll update my example code for PHP

  120. Reply Jared Jun 29, 2012 8:09 am

    For php you have to return the cookie in the header information.

    If you try using setcookie("fileDownload",”true”, 0, "/"); you will get a successful download but the UI dialog box will not close.

    example.

    header('Set-Cookie: fileDownload=true');
    header('Cache-Control: max-age=60, must-revalidate');
    header("Content-type: text/csv");
    header('Content-Disposition: attachment; filename="'.$title.'-' . $timestamp . '.csv"');

  121. Reply Anuj Gupta Jun 3, 2012 5:30 am

    Hello John

    I have used the same code that you have given but in simple ASP.Net , What should be the URL Passed in the link , I am giving the path of the pdf, But it is going to the Failure , what could be the reason, I will be really great full if you can help me on this.

    Anuj

  122. Reply Kumar May 30, 2012 2:52 pm

    Plugin is unable to download 'dat' and 'jpg' files. I am not sure whats going wrong? Your comments would be appreciated. Thanks.

  123. Reply Mason Liu May 29, 2012 3:17 am

    There is a issue for Firefox, if my FF prompts me selecting the path to download, and at that time, the temp iframe has already been removed, so the download will not continue, anyway can detect the save as dialog?

  124. Reply John May 29, 2012 12:03 am

    Hi DrTyrell,

    I took a look at the site indicated and it doesn't appear to be running anymore. The cookie should be written along with the response stream that contains the file. In my examples it looks something like "Content-Disposition: attachment; filename=Report0.pdf" to send the file along with the file bytes. The cookie needs to be included in a header with that. Hopefully this helps!

    John

  125. Reply DrTyrell May 23, 2012 2:37 am

    Not sure if I've done this right. I have a gaming site and i'm trying to use your script to give the .exe installing apps a better experience for all the reasons you noted. I've included your modal dialog version of the script. Demo here http://www.stimulus.com/my/cTest.php. What I'm not sure is about the server side cookie. I use a redirect script to track all the download requests in PHP. Prior to setting the header location, I'm setting the cookie to your PHP line above. What happens on IE is that the download script reports a failure, but successfully executes the request. On the Mac (which is not really needed at this moment, but will be later) it flashes the processing dialog and doesn't execute the download at all.

    My question is, do I need to set the cookie AFTER the file download has queued or finished? I would have to write a proxy streaming script to know when its done since I'm linking outside my site. Not a big deal, but not something I saw noted in your example.

  126. Reply John May 10, 2012 10:35 pm

    Hi Ricardo,

    I'm not sure what could cause that issue without doing local debugging of it. Make sure that you have added a script reference to jQuery before your script reference to jQuery file download. Also try calling jQuery file download with the exact same syntax as mentioned in one of my posts to make sure its not a syntax issue (for starters). Hope you get it figured out

  127. Reply Ricardo Gomes May 10, 2012 9:41 am

    Hi John,

    1st of all, very interesting your feature. I am having trouble to use with PHP.

    My Chrome is returning. Do you know why?

    Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'fileDownload'

  128. Reply Emiliano Apr 26, 2012 1:29 pm

    Hi John,

    I have it working!

    Thanks a lot! Great tool!

  129. Reply John Apr 25, 2012 11:07 pm

    Hi Emilliano,

    Are you writing a cookie along with your file download? Unfortunately this is the only way to detect file downloads reliably cross browser. Make sure (using FireBug, Chrome, Fiddler etc.) that your response headers along with the file download contains "Set-Cookie: fileDownload=true; path=/" or else there is no way for jQuery File Download to know that a file download just occurred. I hope this helps!

    John

  130. Reply Emilliano Apr 25, 2012 12:43 pm

    Hi There!
    First of all, great Plugin!

    But I'm having some troubles trying to use it. Since it never stops, this line

    if (document.cookie.indexOf(settings.cookieName + "=" + settings.cookieValue) != -1)

    Is never true, so it doesn't stop, and no success function is fired. It happens on last versions of FF, Chrome and safary.

    Any clue?

  131. Reply John Apr 11, 2012 11:21 pm

    Hey Jeelig,

    Thanks for the feedback. If you are using PhoneGap that actually makes a bit of sense since it probably sees the IFRAME come in (how I implemented this thing) and point at a URL. Without it knowing any better it probably just spawns up a browser to deal with that event since IFRAMEs are generally junk (except in this one case, ha!). Take a look at this forum post I found to help clarify:
    http://groups.google.com/group/phonegap/browse_thread/thread/bd1280d14ff1ff81?pli=1

    Unfortunately this is probably permanent so you may need to find a different solution (perhaps using native code in the device you are targeting even?) Let me know if/what you use to get this figured out!

    John

  132. Reply Jeelig Apr 11, 2012 3:54 am

    First of all, great Plugin. Really usefull.
    I tried in my webbrowser, working properly.
    Does it work on webkit? I mean it does but actually I decided to include this into my phonegap app (using jQuery Mobile) and when i click the link it leaves the application and redirect to the native browser.
    Did I miss something?

  133. Reply John Mar 23, 2012 10:19 am

    Hi Ronnie,

    Thanks for the feedback. Funny thing: I actually noticed the same behavior in IE Tester IE8 mode, the dialog didn't come up. I have fully tested in native IE 6-9 installs and everything appears to work properly in my demo.

    IE Tester is a pretty cool thing for high level testing (I use it for starters on everything that I need cross IE browser support) but sometimes it gets a little weird with things so I'll always finish off testing in a native install. Too bad you can't run multiple IEs on a single box right…

    I'm updating the post to include tested browsers. Let me know if you notice anything else or can think of some cool features to add!

    John

  134. Reply Ronnie Mar 23, 2012 6:15 am

    Hi John

    Have you tested this script in IE8?

    The file download dialog does not show after the initial file generation (animation) completes. I don't personally have IE8 installed, but used IETester instead and is supposed to give accurate behavior.

Leave a Reply