I am passing few parameters via ajax to custom module (fgs_api.module)
and in returns getting JSON data ($results->data)
. I want to use/get that variable ($results->data)
in node--xyz.tpl.php
content template. How can I use that variable in node--xyz.tpl.php
. I am doing in drupal 7.
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
$results = $api->{'getSpecialOfferHomes'}(intval($parameter1), intval($parameter2));
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/pass return data variable from custom module to node--xyz.tpl.php
?