I want to make a post
to a Jelix
script :
{literal}
<script type="text/javascript">
$(function(){
$("#btnCalculerNote").on("click",function(){
iIdUser = $("#id_user").val () ;
$.post(
"{/literal}{jurl 'default:calculerNote', array()}{literal}",
{"id_utilisateur": iIdUser},
function(data)
{
alert ("Calcul des notes terminé") ;
// here I want to get the returned url inside the data param
}
);
});
});
</script>
{/literal}
Inside the "default" controller :
function calculerNote ()
{
$rep = $this->getResponse ("redirect");
...
$rep->action = "default:index"; // default is name of the controller , index is the name of the action inside the default controller
return $rep ;
}
As you can see I want to redirect the page to the "default:index" url. So how to get it inside the function of the $.post
?
I'm not sure your conditions
Why don't your try like this
function calculerNote ()
{
$rep = $this->getResponse ("redirect");
...
return json_encode(['action' => 'default:index'] ;
}
And in js success function you can use like this
window.location.herf = data.action;