我想将post
转换为Jelix
脚本:
{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}
"默认"控制器内部:
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 ;
}
正如你所看到的,我想将页面重定向到"default:index"url。那么,如何将其纳入$.post
的函数中呢?
我不确定你的条件
你为什么不试试这个
function calculerNote ()
{
$rep = $this->getResponse ("redirect");
...
return json_encode(['action' => 'default:index'] ;
}
在js成功函数中,你可以像这样使用
window.location.herf = data.action;