hi i am sending some data to controller method through action function using jquery. but in controller method i am getting null value, please help. i am getting a response from ajax method and then want to send that response to controller method through action function. using apex:param but getting null values in debug
visualforce page
<apex:page controller="SendAgreementExt">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<form id="data" method="post" enctype="multipart/form-data">
<apex:pageBlock >
<apex:pageBlockSection showHeader="false" columns="2">
<apex:pageBlockSectionItem >
<apex:outputLabel value="File Name" for="fileName" />
<input type="text" name="File-Name" value="" />
<input type="hidden" name="Mime-Type" value="application/pdf" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file" />
<input name="File" type="file" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<button>Submit</button>
</apex:pageBlockButtons>
</apex:pageBlock>
</form>
<script type="text/javascript">
$("form#data").submit(function(){
var formData = new FormData($(this)[0]);
$.ajax({
url: 'https://api.na1.echosign.com/api/rest/v5/transientDocuments',
type: 'POST',
headers: {'Access-Token' :'3AAABLblqZhCG8fU-alud8zcDf-N8I68P7yfB6nIi6U_PcCQsnobiSYzIpfzmgYaCMnl2PwcuVlSbk7yS_uNV8BkF8ymc3f2m'},
data: formData,
async: false,
success: function (data) {
document.getElementById("myHiddendid").value = data.transientDocumentId;
myFun(data.transientDocumentId);
//SendAgreementExt.send(data);
},
cache: false,
contentType: false,
processData: false
});
return false;
});
</script>
<apex:form >
<input type="hidden" value="{!documentid}" id="myHiddendid"/>
<apex:actionFunction name="myFun" action="{!send}">
<apex:param name="myParam" value="" id="y" assignTo="{!documentid}" />
</apex:actionFunction>
</apex:form>
</apex:page>
Controller
Public with Sharing Class SendAgreementExt
{
public string LeadMessage{get;set;}
public string documentid{get; set;}
public string docid{get; set;}
public PageReference send()
{
System.debug('VARIABLE documentid------' + documentid);
documentid=Apexpages.currentPage().getParameters().get('documentid');
System.debug('VARIABLE documentid------' + documentid);
//system.debug('==in method');
string passedParam1 =Apexpages.currentPage().getParameters().get('myParam');
string passedParam2 = system.CurrentPageReference().getParameters().get('myParam');
system.debug(passedParam1);
system.debug(passedParam2);
return null;
}
}