简体   繁体   English

Drupal多个自定义模块的ajax调用

[英]Drupal multiple ajax calls to a custom module

I have the following code in my custommodule_menu right now there is one ajax call to it. 我的custommodule_menu中有以下代码,现在有一个ajax调用。 I want to add another and consequently create a new function (a new page callback) to handle it, how would i do this. 我想添加另一个,因此创建一个新函数(一个新的页面回调)来处理它,我该怎么做。

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;
}

You just need to do the following: 您只需要执行以下操作:

$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,

);

Then since no file key is defined in the menus $items array for where the methods are stored, find a_b_ajax_email method in the same file and copy/paste this and rename to a_b_ajax_new_page. 然后,由于在菜单$ items数组中未定义用于存储方法的文件密钥,因此请在同一文件中找到a_b_ajax_email方法并将其复制/粘贴并重命名为a_b_ajax_new_page。 Then go ahead and change the functionality to suit your needs. 然后继续并更改功能以适合您的需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM