[英]Can't get parameters passed to page callback
I created a module in drupal php then i created a select : 我在drupal php中创建了一个模块,然后创建了一个select:
<select name="form" id="room">
<option value="0" text="" ><?= t('Select a value')?></option>
<option value="1" text="admin_service_participant"><?= t('Services participants')?> </option>
<option value="2" text="admin_service_candidat"><?=t('Services candidats')?></option>
<option value="3" text="admin_service_nomine"> <?=t('Services nominés')?></option>
<option value="4" text="admin_service_gagnant"><?=t('Services gagnants')?></option>
</select>
<div id="list"></div>
<script>
jQuery(document).ready(function () {
jQuery('#room').change(function () {
var numero = jQuery(this).val();
jQuery.ajax({
url :'<?= url("admin/get-admin-statistique/%")?>',
data: numero,
type: "POST",
success: function (datad) {
jQuery('#list').html(datad);
},
error: function () {
alert("Erreur de récupération");
}
})
});
});
</script>
I got 4 template which i one to load with ajax on change, i implemented a hook_menu for this methode with 1 argument: 我有4个模板,可以在更改时用ajax加载,我为带有1个参数的此方法实现了一个hook_menu:
$items['admin/get-admin-statistique/%'] = array(
'title' => t('Admin Statistiques'),
'page callback' => 'GetStatistique',
'page arguments' => array(1),
'type' => MENU_CALLBACK,
'access callback' => TRUE,
);
and the methode : 和方法:
function GetStatistique($numero){
if($numero==1)
{
return theme('admin_service_candidat',array());
}
elseif ($numero==2)
{
return theme('admin_service_candidat',array());
}
elseif($numero==3)
{
return theme('admin_service_nomine',array());
}
elseif($numero==4)
{
return theme('admin_service_participant',array());
}
}
the probleme is my parametre is null , $numero =0 i don t know why my methode Getstatistique don't get the number 问题是我的参数为null,$ numero = 0我不知道为什么我的方法Getstatistique没有得到数字
Best regards. 最好的祝福。
Try like this way.... 像这样尝试。
url:Drupal.settings.basePath + 'admin/get-admin-statistique/'+numero
and remove data
from your ajax request. 并从ajax请求中删除data
。
I think this may be useful for you. 我认为这可能对您有用。
Thanks, 谢谢,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.