Could you please to help this? I'm very new with javascript.I have tried many way but it doesn't work. I have problem with javascript function I have tried to call method from controller but it doesn't work. I already provide my code as below. AS my understand, The method from my controller doesn't call from javascript function because I have check in dev console. My controller doesn't excute. However, I tried to console log values in javascript function. Both variable have values. and I have found this error in my webconsole.
"HTTP-Based Public Key Pinning is deprecated. Chrome 69 and later will ignore HPKP response headers. (Host: hpcc-testliveagenthp.cs72.force.com) "
Thank you in advance
My VF
<textarea id="comment" cols="50" row="10" values="{!surveycomments}" ></textarea>
<button class="btn btn-sucess" type="button" id="postchat_submit" onclick="doSave();">Submit</button>
Javacript
<script>
function doSave(){
var comments = document.getElementById("comment").value;
console.log('comment is '+comments);
var ChatKey = '{!$CurrentPage.parameters.ChatKey}'
console.log('ChatKey is '+ChatKey);
HPCC_PostChatSurveyController.saveSurvey(ChatKey, comments, function(result, event){
if(event.type === 'exception'){
console.log("Exception");
console.log(event);
}
else if (event.status){
console.log(result);
if(result = 'Success'){
alert("Successfully save! Thank you")
}
} else{
console.log(event.message);
}
});
}
</script>
Controller
public with sharing class HPCC_PostChatSurveyController {
public LiveChatTranscript livechatObj {get; set;}
public String surveycomments {get; set;}
public HPCC_PostChatSurveyController() {
surveycomments = '';
}
@RemoteAction
public static String saveSurvey(String chatkey, String comments){
try{
String key = chatkey;
LiveChatTranscript liveObj = new LiveChatTranscript();
liveObj = [SELECT Id, ChatKey , HPCC_Comment__c FROM LiveChatTranscript WHERE ChatKey=: key LIMIT 1];
liveObj.HPCC_Comment__c = comments;
update liveObj;
return 'Success';
}catch(Exception e){
system.debug('Exception: '+e.getMessage());
return 'Exception';
}
}
}
I also tried javascript like below
Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.HPCC_PostChatSurveyController.saveSurvey}',JSON.stringify(ChatKey), JSON.stringify(comments),function (result, event) {
if (event.statusCode == 200) {
// yay!
}
}, { escape : false })