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
Scott McArthur 8Scott McArthur 8 

jquery in Lightning components

Does anyone have any examples of how to make a jQuery get from a Lightning component using code similar to the below where the data will be returned from SOQL query in Salesforce

 jQuery.ajax({
            url: '/MCS/GetCar', 
            type: "GET",
            dataType: "json",

I am already aware of how to import the jquery library using '<ltng:require' and creating an @AuraEnabled method in Apex but it was wiring the rest together I was unsure about, I am relatively new to Lightning although aware of the basics.
Tanuj TyagiTanuj Tyagi
Hi Scott McArthur 8 ,
I am not sure why you want to use Jquery to call your apex controller , but you can use javascript if you want 

you can write this in your js controller:: 

  methodName:function(component,event,helper){

// Calling Apex Controller 
        var action = component.get("c.apexControllerMethodName");
        action.setParams({
            "parameter":value you wanto pass
        });
        
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state == "SUCCESS"){
                 
        // do your stuff 


            }else{
                console.log("Failed with state: " + state);
              
                    }
                
        });
        $A.enqueueAction(action);  
}