简体   繁体   English

jQuery ajax调用httphandler返回zip文件

[英]jQuery ajax call to httphandler returning zip file

I have an httphandler that creates a zip file and returns it for download. 我有一个httphandler,它创建一个zip文件并返回下载。

context.Response.AppendHeader("content-disposition", "attachment; filename=myfile.zip"); context.Response.AppendHeader(“content-disposition”,“attachment; filename = myfile.zip”);

Is it possible to call the handler from a jquery ajax call? 是否可以从jquery ajax调用中调用处理程序? If yes, what kind of dataType should I declare? 如果是,我应该声明什么样的dataType?

Thanks 谢谢

What I would suggest here is not to return the ZIP file through Ajax, but create it and return a link to it (or the error message). 我在这里建议的不是通过Ajax返回ZIP文件,而是创建它并返回它的链接(或错误消息)。 Then you can process the response and either show the error or allow the user to download from the link. 然后,您可以处理响应并显示错误或允许用户从链接下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM