ColorBox – a jQuery lightbox. ColorBox is one of the most popular modal pop-ups / lightbox which have been around for a while. This library has been used to implement a huge number of different types of Ajax popup windows and it is used in literally millions of websites (at least 1.9 million sites at the time of writing).
If I understand your question correctly you can't actually perform a file download with Ajax directly. You can request a file using Ajax but your Ajax response will contain the actual bits for the file. Due to JavaScript security limitations you won't be able to save those bits onto the user's computer with a file download dialog. For more information on why this is take a look at my blog postI created the which fixes the problem and provides some other nice features.
It basically gives you a 'full Ajax-like' experience for file downloads (complete with callbacks even) that isn't normally possible for file downloads. It also has some other handy features:- User never leaves the same page they initiated a file download from whether it is successful or there is an error- successCallback and failCallback functions allow for you to be explicit about what the UI behavior is 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 for more example. When answering a question please:. Read the question carefully. Understand that English isn't everyone's first language so be lenient of badspelling and grammar. If a question is poorly phrased then either ask for clarification, ignore it, oredit the question and fix the problem.
Insults are not welcome. Don't tell someone to read the manual. Chances are they have and don't get it.Provide an answer or move on to the next question.Let's work to help developers, not make them feel stupid.
I am little new to JS. I have been searching for the similar answer for a while. I get a response from server like following:Content-Disposition:attachment; filename=Agency1.zipContent-Type: application/octet-streamDate: 2016 May 5 19:41:32+4m 53sServer: Apache-Coyote/1.1Transfer-Encoding: chunkedNow the task is to download this response(a.zip file) on User's local system without user being redirected to an URL or a prompt asking him/her to click a button to download the this zip file. After making an AJAX(POST) request I get a success data. Now I do not know how to proceed.I tried the solution provided by you.
It does not make a call to the URL provided neither does it throw an error. Also, can you tell me how will one handle 'on success' and 'on error' call back from server response when the solution works. Kindly pardon me if I am being naive here. I am little clueless and new to this:).
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |