function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Muhammad Hammad 8Muhammad Hammad 8 

How do I pass data from controller to javascript

global class demo{
    global static String getSettings(){
        user__c setting = user__c.getInstance();
        return setting.data__c;
    }
}
 
<apex:page docType="html-5.0"  controller="demo" >


<apex:form >
        <apex:actionFunction name="hello" action="{!getSettings}"  />
</apex:form>

<script>
    window.setTimeout(
console.log(hello())
,1000)
</script>

</apex:page>
I'm following this (https://youtu.be/aqztf1nJv-k?t=1944) tutorial for protected custom settings and I want to show this data using javascript. 
 
ShivankurShivankur (Salesforce Developers) 

Hi Muhammad,

Please check out below blog, which would help you on how to pass values from apex controller to javascript.

https://blog.jeffdouglas.com/2011/01/17/passing-values-to-javascript-from-apex-controller-method/

Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.