When I click a button on the client side I want to invoke a public static webmethod on the server side using AJAX. The static method will create the appropriate file. After the file is created I need to download it to the client desktop. I’ve found John Culvinar’s jquery filedownload plugin but haven’t been able to implement it so far. I know that using this plugin also requires writing a cookie so that it knows that the download is complete. Where do I put this code in the server side? After creating the file? I’d be very glad if someone could show me a sample on this scenario, maybe on jsfiddle.net
Share
I suggest replacing your ajax request with a hidden iframe, then when your server returns said file, it will automatically ask the user to download it.
(The above code was original adapted from http://www.bennadel.com/blog/1244-ColdFusion-jQuery-And-AJAX-File-Upload-Demo.htm)
An alternative would be to make it a two step process. Step 1 generates the file and returns a url, step 2 the user clicks download ( which would be an anchor tag pointing at said url).