Add json parameters to the json output of an elgg action called by ajax

Hi everyone,

I'm calling an elgg action in my javascript : 

elgg.action('myUrl', {
data:data,
 success: function(json) { if (json.thisThingWasDone) // do something... }

}

I would like to add the parameter "json.thisThingWasDone" to the response of the action... How do I do that ?

 

 

 

 

 

 

 

 

 

 

  • then ...
    my question was like this. I will leave here my answer.

    needed to know how the ELLG would answer the json, then did so:

    at the end of my action:

                if ($result) {
                    $response = uploaded_track_response($track);
                    header("Content-Type: application/json");
                    header("Content-Length: " . strlen($response));
                    echo $response;
                }

    and my function at the library:

    function uploaded_track_response($data){
        
        $response = ["array with your data"];
        
        $json = json_encode($response);    

        return $json;
        
    }

    :D