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
Surender reddy SalukutiSurender reddy Salukuti 

Lightning _eroor1

Hi Every one,
 i am new to lightning know i am learning Lightning.

actually i am invoking Apex class in Lightning

 i wrote the program

Apex class:
public class Lghtning_1 {
  @AuraEnabled
    public static string callme(){
        return 'surender reddy';
    } 
}
Lightning component:
<aura:component controller="Lghtning_1">
    <aura:attribute name="Result" type="string"/>
    <lightning:button label="submit" onclick="{!c.show}"/>
    
    Result:{!v.Result}
</aura:component>

Controll.js 
({
    show : function(component, event, helper) {
        
        var abc =component.get("c.callme");
        abc.setCallback(this,function(response){
            var state=response.getstate();
            if(state==="success"){
               var Result=response.getReturnvalue();
               component.set("v.Result",Result);
               }
        });
        $A.enqueueAction(abc);
        
    }
})
Applicatino call:
<aura:application >
    <c:Light_Apex/>
    </aura:application>
actually when i am execting this program i am getting error message like below

This page has an error. You might just need to refresh it. Error in $A.getCallback() [response.getstate is not a function] Callback failed: apex://Lghtning_1/ACTION$callme Failing descriptor: {c:Light_Apex}
plese help me any one.

Thank you
Surender Reddy.

 
Yogeshwar TailorYogeshwar Tailor
Hi Surender,

Change your js controller code as below.
 
var state=response.getState();
if(state==="SUCCESS"){
        var Result=response.getReturnvalue();
         component.set("v.Result",Result);
}

Try it. If it will not work please let me know.

Thanks,
Yogesh