You need to sign in to do that
Don't have an account?
Surender 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.
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.
Change your js controller code as below.
Try it. If it will not work please let me know.
Thanks,
Yogesh