i was doing a page/script/controller functionality just see how it works, and for some reason i get the error "Visualforce is not defined".
From what i got searching, this error shows when you dont add the controller to your page, but in my case it is there, heres the code:
Page:
<apex:page controller="ControllerTest" sidebar="false">
<apex:pageBlock>
<apex:pageBlockSection>
<p id="test">
Click
</p>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:includeScript value="{!$Resource.testScript}" loadOnReady="true" />
</apex:page>
Script:
const button = document.getElementById("test");
console.log("Script OK");
Visualforce.remoting.timeout = 120000;
function testFunction(){
Visualforce.remoting.Manager.invokeAction('ControllerTest.test', (result, event){
console.log("invokeAction Okay!");
});
}
button.onclick = () => {
testFunction();
}
Controller:
public class ControllerTest{
public ControllerTest(){}
public static void test(){
System.debug('Gotcha');
}
}