I'm working on the client-side portion of a project and have a situation that currently recieves a block of XML data from the server, and I'm trying to take that information and prompt a user download with it. Is this possible?
Here's my code:
var holder =
jQuery.ajax({
type: "POST",
url: "xml_comes_back.json",
data: {param : info,
param2 : info2
},
dataType: ($.browser.msie) ? "text" : "xml",
success: function(data) {
$('#selector').prev().empty().html('<a href="' + data + '" id="download">Ready for Download</a>');
$('#download').click(function() {
//Prompt download for xml stored in 'data' here
});
},
error:function (xhr, ajaxOptions, thrownError) {
alert('error')
}
});
}
I'm having major issues trying to achieve this. Is it possible to have this file download without the server create and store it by a URL? I want to just recieve the data dynamically with the proper headers and have the download link work.
Here is the response header coming back from the ajax call success:
Content-Disposition:attachment; filename=theFile.xml
Content-Type:application/force-download;charset=UTF-8