0

I am trying to use result['data'] to new custom module. fgsis theme and all are custom template and modules.

I have module fgs_api.module where I have function which returns results->data and get data via ajax and now I would like to get those data into new module.

In module fgs_api.module

function fgs_api_data_execute($parameter1, $parameter2)
{   
    if(!is_null($parameter1) && !is_null($parameter2))
    {
        // my custom code which is working 

        if($results->success)
        {
            $return = fgs_api_format_return(false, $results->data);
        }else{
            $return = fgs_api_format_return(true, $results->message);
        }
    }else{
        $return = fgs_api_format_return(true, 'Incorrect parameters');
    }
    return $return;
}

In Js

  var url = '/fgs_api_data_execute/' + parameter1 + '/' + parameter2;    
                console.log(url);

                $.ajax({
                    url: url,
                    type: 'POST',
                    dataType: 'json',
                    success: function (result) {   
                        if (result.data) {
                             console.log(result['data']);  // use this data in Module           
                        }else {
                           console.log("error");
                        }
                    },

How can I use that result['data'] in another custom module?

  • Maybe dumb question but as I seem to not understand what's going on I'll ask anyway: You have a function in your theme and want to execute it in your module? What's happening when you just call the function in the module? And what's that Ajax about? Can you please edit your question to add clarification or a step by step to reproduce this issue? Many thanks 🙏🏻 – leymannx Mar 14 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.