[英]Drupal multiple ajax calls to a custom module
我的custommodule_menu中有以下代碼,現在有一個ajax調用。 我想添加另一個,因此創建一個新函數(一個新的頁面回調)來處理它,我該怎么做。
function a_b_menu() {
$items['/a_b/email/%'] = array(
'page callback' => 'a_b_ajax_email',
'type' => MENU_CALLBACK,
'page arguments' => array(1),
'access arguments' => array('access content'),
'access callback' => TRUE,
);
return $items;
}
您只需要執行以下操作:
$items['/a_b/email/%'] = array(
'page callback' => 'a_b_ajax_email',
'type' => MENU_CALLBACK,
'page arguments' => array(1),
'access arguments' => array('access content'),
'access callback' => TRUE,
);
$items['/a_b/new_page/%'] = array(
'page callback' => 'a_b_ajax_new_page',
'type' => MENU_CALLBACK,
'page arguments' => array(1),
'access arguments' => array('access content'),
'access callback' => TRUE,
);
然后,由於在菜單$ items數組中未定義用於存儲方法的文件密鑰,因此請在同一文件中找到a_b_ajax_email方法並將其復制/粘貼並重命名為a_b_ajax_new_page。 然后繼續並更改功能以適合您的需求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.