0

I submitted an ajax form as

var formData = new FormData();
formData.append('name', 'John');
formData.append('company', 'ABC');

$.ajax({
  url: url,
  data: formData,
  processData: false,
  contentType: false,
  success: function(data){},
  error: function(err){}
});

Now I am getting the data on success from the server. But it is in encoded format. Hence the file is not downloading on the browser. When I look in the browser, data comes up as garbage encoded values.

Is there a way, I can decode this data and download the file on browser.

user544079
  • 16,109
  • 42
  • 115
  • 171
  • 4
    "encoded format"? Btw, if you want to download a file, don't use Ajax. – GolezTrol Jun 26 '14 at 20:11
  • what type of data are you trying to retrieve? JSON,XML,Text, Raw Binary? – Patrick Evans Jun 26 '14 at 20:15
  • It should download as an excel file. In the browser I am seeing encoded data. So how do I download it? – user544079 Jun 26 '14 at 20:17
  • _"is there a way I can decode this data?"_ - almost certainly, but unless you show a sample here there's no chance you'll get a useful answer. – Alnitak Jun 26 '14 at 20:19
  • There is nothing to decode. What you see in the browser is the same as what you would see if you opened the file in Notepad: the contents. To download a file, navigate to the url and make sure the server (Apache or PHP) returns the proper headers. Javascript cannot save a datastring to a file. – GolezTrol Jun 26 '14 at 20:21

0 Answers0