I want to download a file by going through .aspx page and which returns a file like this
Response.Clear();
string content = Request.QueryString["param1"]+Request.QueryString["param2"]
Response.AddHeader("Content-Disposition", "attachment; filename=HelloWorld.txt");
Response.ContentType = "APPLICATION/OCTET-STREAM";
Response.AddHeader("Content-Length", content.Length.ToString());
Response.Write(content);
Response.End();
and in my main page:
$('#SaveFileBtn').click(function () {
$.ajax({
async: true,
type: "POST",
url: 'CreateKeyFile.aspx',
data:{param1:12,
param2:a},
success: function (data) {// code to download the recieved data
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
alert("Error");
}
});
return false;
});
I tried to use an iframe.src and give it my url but I charging a url with a massive size and the use of iframe will limit it to 256 caraters only ! so how can I do it with SP javascript api or if it's possible with ajax ?