Reputation: 736
I use jQuery to post some data to page and download zip file using zip library in CodeIgniter, it only outputs some string data and downloading doesn't work.
Code:
$data = json_decode($data);
foreach ($data as $id) {
$this->db->where('idjobs', $id);
$this->db->where('jobs_has_clients.jobs_idjobs', $id);
$this->db->join('status', 'status.idstatus = jobs.status_idstatus', 'left');
$this->db->join('jobs_has_clients', 'jobs_has_clients.jobs_has_clientsSet = status.statusFor', 'left');
$this->db->join('cv', 'cv.clients_idclients = jobs_has_clients.clients_idclients', 'left');
$get_all_data_q = $this->db->get('jobs');
$all_data_to_array_q = $get_all_data_q->result_array();
$a = 0;
foreach ($all_data_to_array_q as $zipData) {
$path = './' . $zipData['cvFilePath'];
$this->zip->read_file($path);
$a++;
}
if ($a != 0) {
$this->zip->download('job_' . $id . '_' . date('Y-m-d') . '_cv_archive.zip');
}
}
Upvotes: 3
Views: 821
Reputation: 1913
You can't launch a download from an Ajax query. You should load your script from your browser, not from jQuery.
Upvotes: 3