下载的zip文件从阿贾克斯岗位要求的jQuery [英] Download zip file with jquery from ajax post request

查看:95
本文介绍了下载的zip文件从阿贾克斯岗位要求的jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能做一个ajax post请求到一个特定的URL和接收数据,只要求一个zip文件?或者,我要送两个请求......之一,为了让已经建立的服务器里面的zip文件的URL和一个又一个下载的zip文件?

I would like to know if it's possible to do an ajax post request to a specific url and receive in data a zip file in only on request? Or I have to send two requests... one, in order to have the url of the zip file inside the server which has been created and an another to download the zip file?

推荐答案

本机的答案是否定的!

但你可以做到这样。

您的Ajax请求:

$.ajax({
    url: 'your-url-that-gives-zip-file.php',
    dataType: 'JSON',
    success: function(response){
        if(response.zip) {
            location.href = response.zip;
        }
    }
});

你的PHP文件:

Your php file:

<?php

//Get your zip file code with and combine with http://youradress.com

$zipFile = 'http://youraddress.com/downloads/'.$zipFile;

echo json_encode(array('zip' => $zipFile));

?>

这篇关于下载的zip文件从阿贾克斯岗位要求的jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆