php - CodeIgniter's force_download() problems -


i'm trying generate .json file download using codeigniter's force_download() in ajax call, doesn't work expected.

here ajax call:

$.ajax({     url: /myfunction,      type: 'post',      data: {value_sent: my_json_array} }); 

and php function:

public myfunction() {     $dl_array = $this->input->post("value_sent");     $this->load->helper('download');     force_download("file.json", $dl_array); } 

data sent (i double checked), download prompt never shown. assume force_download() fails, don't understand why.

any appreciated, thanks!

this isn't problem codeigniter, it's limitation of javascript. can't download files via ajax, referenced in download file jquery.ajax.

you can't through ajax because javascript cannot save files directly user's computer (out of security concerns)


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -