I'm trying to generate a .json file to download using CodeIgniter's force_download() in an Ajax call, but it doesn't work as expected.
Here is my Ajax call:
$.ajax({
url: /myfunction,
type: 'POST',
data: {value_sent: my_json_array}
});
And my PHP function:
public myfunction()
{
$dl_array = $this->input->post("value_sent");
$this->load->helper('download');
force_download("file.json", $dl_array);
}
Data is sent (I double checked), but download prompt is never shown. I assume force_download() fails, but I don't understand why.
Any help is much appreciated, thanks!