0
我想打一個post
到Jelix
腳本:如何使用post的成功函數的數據參數?
{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 ;
}
正如你可以看到我想要的頁面重定向到「默認:指數「網址。那麼如何讓它在$.post
的功能裏面呢?
從重定向的控制器post方法..只是發回一些json令牌值回ajax調用,然後使用'location.href = ...'在ajax回調內重定向。 –
那麼應該由json返回的值是什麼? – pheromix
雖然我不熟悉php,但可能是您可以返回您想要重定向爲json對象的url,然後在ajax成功回調中使用它來重定向。 –