You need to sign in to do that
Don't have an account?
Surender reddy Salukuti
Lightning_error
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. Action failed: c:Light_Apex$controller$show [abc.setcallback is not a function] Failing descriptor: {c:Light_Apex$controller$show}
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. Action failed: c:Light_Apex$controller$show [abc.setcallback is not a function] Failing descriptor: {c:Light_Apex$controller$show}
plese help me any one.
Thank you
Surender Reddy.
JavaScript is case sensitive. The function name which you have defined is not a valid one.
Please try the below code which works fine. The function name which you are using in your code is abc.setcallback, but it should be abc.setCallback.
Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
Try below code for your javascript controller.
Marked the changes in bold letters.
Please let me know if it will not workout.
Thanks,
Yogesh