Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery可以检索文件吗?_Jquery_Html_Ajax_File - Fatal编程技术网

jQuery可以检索文件吗?

jQuery可以检索文件吗?,jquery,html,ajax,file,Jquery,Html,Ajax,File,我有一个django应用程序,可以创建xls和txt文件 我正在尝试创建一个按钮,它向django发送一个jQuery.get请求,django然后将一个新创建的文件返回给jQuery,jQuery会弹出一个另存为对话框 我的代码如下所示: jQuery("#testButton").live("click",function() { jQuery.jGrowl("click"); jQuery.get("/filetest",function(data){}); });

我有一个django应用程序,可以创建xls和txt文件

我正在尝试创建一个按钮,它向django发送一个jQuery.get请求,django然后将一个新创建的文件返回给jQuery,jQuery会弹出一个另存为对话框

我的代码如下所示:

jQuery("#testButton").live("click",function()
{
    jQuery.jGrowl("click");
    jQuery.get("/filetest",function(data){});

});


<div id="testButton" class="button">CLICK TO TEST</div>
jQuery(#testButton”).live(“单击”,函数()
{
jQuery.jGrowl(“单击”);
get(“/filetest”,函数(数据){});
});
点击测试
将文件获取到jQuery很容易,但我不知道如何启动一个另存为对话框


任何帮助都会很棒

一个
窗口如何。打开
调用,打开一个服务器端文件,该文件将发送文件附件的内容类型以及内容正文中的文件内容?

您可以在页面中使用iframe,并使用jquery将源代码更改为要下载的文件

此代码放在html正文中:

<iframe id="download" style="width:0px;height:0px;display:none;"></iframe>

在服务器端,当请求内容类型为make_excell时,将文件发回
我通过插件找到了另一种方法
$('#download').attr("src",location.href+"&make_excell=1");