I am trying to download the data which is coming from Apex Class to be download in Text format to the Page whenever on clicking a button. i.e, If any one Clicks the Quick Download Button, The Data generating on Apex Class should be download in a text.
Here is my Visualforce Page Code,
<apex:page standardController="Account" Extensions="CreateFileAndDownloadOntheFly" showChat="false" sidebar="false" showHeader="false">
<apex:includeScript value="{!URLFOR($Resource.filesaver, 'filesaver.js')}"/>
<script type="text/javascript">
function myFunction(){
var con = confirm('Please confirm to download');
if(con){
var recordId = '{!Account.Id}';
FileDownload();
var files = response;
var blob = new Blob([files], {type: "application/text",endings: "native"});
saveData(blob,"document.txt");
}
else{
alert('You cancelled the Process');
}
}
</script>
<apex:form>
<apex:actionFunction name="FileDownload" action="{!FileDownload}">
<apex:param assignTo="{!pId}" name="AcctId" value="{!Account.Id}"/>
</apex:actionFunction>
<apex:commandButton value="Quick Download" onclick="myFunction();"/>
</apex:form>
</apex:page>
My Problem is, I am not able to send the Account ID to the Controller for the Operation. Does anyone know how to send the Id from Javascript to Controller?
NOTE: I cannot use the ApexPages.currentPage().getParameters().get('id'); I have to use only the Javascript and need to send the ID.
Any suggestion would be great...
Thanks in advance.