0

The framework is Codeigniter. I have an array by a response from ajax call which is converted to a CSV file and stored as CsvString = "data:application/csv," + encodeURIComponent(array_name); method. Now I need to download this CsvString. I have checked File transfer plugin but it required a URL which is not applicable in my case. Is there any alternative way. File Transfer plugin required URL which is not applicable in my case.

fileTransfer.download(
    uri,
    fileURL,
    function(entry) {
        console.log("download complete: " + entry.toURL());
    },
    function(error) {
        console.log("download error source " + error.source);
        console.log("download error target " + error.target);
        console.log("download error code" + error.code);
    },
    false,
    {
        headers: {
            "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
        }
    }
);

I already generated the file by ajax call all I need to download it.

Vickel
  • 6,356
  • 6
  • 30
  • 49
dspillai
  • 116
  • 6
  • Why can't you make download csv from server side i mean codeigniter side? – turivishal Jun 06 '20 at 09:02
  • As far as I understand Phnegap used a plugin called File Transfer to download files. I have checked the plugin and it required a URL parameter and in my case URL not required because the file already generated by AJAX call. – dspillai Jun 06 '20 at 12:37
  • does this answer your question https://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side – turivishal Jun 06 '20 at 12:59
  • It's working only in the browser, not in the PhoneGap app. – dspillai Jun 06 '20 at 14:13

0 Answers0