JQuery Excel export issue

会有一股神秘感。 提交于 2019-12-08 06:46:32
Oleg

I think that you can't open Excel if you use HTTP POST. The way which will work is to use HTTP GET and encode parameters which you need in the URL:

window.location = "http://devmachine:9010/axis/StdPartSearchServlet?" +
    $.param({someParamName: "someValue", anotherParam: 123});

In the way the web browser will opens the returned data as PistonData.xls specified in Content-Disposition header with respect of the application registered for application/vnd.ms-excel (see Content-Type header). See the answer for more details.

If you need to prevent uncontrolled caching of the XLS data returned from the server I would recommend you to set additional HTTP header "Cache-Control: max-age=0" or better "Cache-Control: private, max-age=0" to prevent caching without re-validation on the HTTP proxy. See here, here for additional information.

If you are trying to use jquery to download the file, maybe you should look here:

http://www.filamentgroup.com/lab/jquery_plugin_for_requesting_ajax_like_file_downloads 1

This has a working snippet to do what you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!