开发者

jQuery File Save As dialog for dynamic content

开发者 https://www.devze.com 2023-01-02 02:31 出处:网络
I\'ve a servlet that is invoked via jquery ajax. The resulting XML is t开发者_StackOverflowhen transformed using XSL and displayed on screen. Now, the requirement is to either print or save this conte

I've a servlet that is invoked via jquery ajax. The resulting XML is t开发者_StackOverflowhen transformed using XSL and displayed on screen. Now, the requirement is to either print or save this content to the local machine. The print portion is working fine but I'm stuck at the Save As part. How do I do this using jquery/javascript? I'm using IE8/XP.

I tried

document.execCommand('SaveAs');

on button click but it doesn't seem to work in IE8. It shows the alerts I put in till that point, but doesn't bring up the dialog box. What's going wrong here?


If you can do this using server-side code instead of javascript then set the content-disposition header:

Content-Disposition: attachment
0

精彩评论

暂无评论...
验证码 换一张
取 消