我在 JavaScript 中有两个数组:
var xcoord = [];
经过var ycoord = [];
一些处理,每个数组包含 15 个数值。我想将此数据发送到 Drupal 中的菜单回调。
我的 AJAX 代码:
$.post('http://mysite.com/?q=menu_example/my_page',
{'ycoord[]': ycoord, 'xcoord[]': xcoord }
);
Drupal PHP:
$items['menu_example/my_page/%/%'] = array(
'title' => 'My Page',
'description' => 'i hope this works',
'page callback' => '_graphael',
'page arguments' => array(2, 3), // fill this,
'access callback' => true,
'type' => MENU_CALLBACK,
);
在我的控制台中,我看到 和 的值xcoord
正在ycoord
正确传输,但回调并不能正常工作。我的问题:如何将数组传递给菜单回调?我还应该在密钥中使用%
占位符吗?$items