I'm trying to see what is my RemoteAction result however the page reloads before it happens.
How can I stop this?
VF Page:
<button class="btn-enter-panel" onclick="getRemoteName()">enter <i class="fa fa-long-arrow-right"></i></button>
JS Code:
<script type="text/javascript">
function getRemoteName() {
var fieldContent = $('.elementClassId').val();
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.MyController.searchName}'
,fieldContent
,function(result, event){
if (event.status) {
if(result != null){
console.log('result');
console.log(result);
//do something
}
else
{
console.log('Here I am not');
}
} else if (event.type === 'exception') {
console.log('exception');
} else {
console.log('Beyond exception');
}
}
, {escape: true}
);
}
</script>
I've tried to follow this link JavaScript remoting reloading page but did't fit to my problem or I missunderstand how to apply in my case