1. <legend id='MJNwf'><style id='MJNwf'><dir id='MJNwf'><q id='MJNwf'></q></dir></style></legend>
  2. <tfoot id='MJNwf'></tfoot>
      <bdo id='MJNwf'></bdo><ul id='MJNwf'></ul>
    <i id='MJNwf'><tr id='MJNwf'><dt id='MJNwf'><q id='MJNwf'><span id='MJNwf'><b id='MJNwf'><form id='MJNwf'><ins id='MJNwf'></ins><ul id='MJNwf'></ul><sub id='MJNwf'></sub></form><legend id='MJNwf'></legend><bdo id='MJNwf'><pre id='MJNwf'><center id='MJNwf'></center></pre></bdo></b><th id='MJNwf'></th></span></q></dt></tr></i><div id='MJNwf'><tfoot id='MJNwf'></tfoot><dl id='MJNwf'><fieldset id='MJNwf'></fieldset></dl></div>

      <small id='MJNwf'></small><noframes id='MJNwf'>

      如何将数组传递给 Drupal 菜单回调

      How to Pass Arrays to Drupal Menu Callbacks(如何将数组传递给 Drupal 菜单回调)

    1. <legend id='UXstz'><style id='UXstz'><dir id='UXstz'><q id='UXstz'></q></dir></style></legend>
        <tfoot id='UXstz'></tfoot>

            <tbody id='UXstz'></tbody>
            <bdo id='UXstz'></bdo><ul id='UXstz'></ul>
              • <small id='UXstz'></small><noframes id='UXstz'>

              • <i id='UXstz'><tr id='UXstz'><dt id='UXstz'><q id='UXstz'><span id='UXstz'><b id='UXstz'><form id='UXstz'><ins id='UXstz'></ins><ul id='UXstz'></ul><sub id='UXstz'></sub></form><legend id='UXstz'></legend><bdo id='UXstz'><pre id='UXstz'><center id='UXstz'></center></pre></bdo></b><th id='UXstz'></th></span></q></dt></tr></i><div id='UXstz'><tfoot id='UXstz'></tfoot><dl id='UXstz'><fieldset id='UXstz'></fieldset></dl></div>
                本文介绍了如何将数组传递给 Drupal 菜单回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在 JavaScript 中有两个数组:var xcoord = [];var ycoord = [];经过一些处理,每个数组包含 15 个数值.我想将此数据发送到 Drupal 中的菜单回调.

                I have two arrays in JavaScript: var xcoord = []; and var ycoord = []; After some processing, each array contains 15 numeric values. I'd like to send this data to a menu callback in Drupal.

                我的 AJAX 代码:

                My AJAX code:

                $.post('http://mysite.com/?q=menu_example/my_page', 
                    {'ycoord[]': ycoord, 'xcoord[]': xcoord }
                );
                

                Drupal PHP:

                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,
                );
                

                在我的控制台中,我看到 xcoordycoord 的值正在正确传输,但回调并不完全正常.我的问题:如何将数组传递给菜单回调?我还应该在 $items 键中使用 % 占位符吗?

                In my console, I see that the values for xcoord and ycoord are being properly transmitted, but the callback isn't quite working. My question: how would I pass arrays to a menu callback? Should I still use a % placeholder in the $items key ?

                推荐答案

                您传递给 $.post() 的第二个参数未附加到您作为第一个参数传递的 URL;它是在 $_POST 中传递给 PHP 的数据.

                The second argument you pass to $.post() is not attached to the URL you pass as first argument; it is data that is passed to PHP in $_POST.

                菜单回调的正确定义应如下所示.

                The correct definition for the menu callback should be the following one.

                $items['menu_example/my_page'] = array(
                  'title' => 'My Page', 
                  'description' => 'I hope this works', 
                  'page callback' => '_graphael', 
                  'access callback' => TRUE,
                  'type' => MENU_CALLBACK,
                );
                

                您的页面回调应该会在 $_POST 中找到从 jQuery 传递的数据.

                Your page callback should then find the data passed from jQuery in $_POST.

                这篇关于如何将数组传递给 Drupal 菜单回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='EwN8q'></small><noframes id='EwN8q'>

                  • <bdo id='EwN8q'></bdo><ul id='EwN8q'></ul>
                      <legend id='EwN8q'><style id='EwN8q'><dir id='EwN8q'><q id='EwN8q'></q></dir></style></legend>
                        <tbody id='EwN8q'></tbody>
                      <tfoot id='EwN8q'></tfoot>

                          <i id='EwN8q'><tr id='EwN8q'><dt id='EwN8q'><q id='EwN8q'><span id='EwN8q'><b id='EwN8q'><form id='EwN8q'><ins id='EwN8q'></ins><ul id='EwN8q'></ul><sub id='EwN8q'></sub></form><legend id='EwN8q'></legend><bdo id='EwN8q'><pre id='EwN8q'><center id='EwN8q'></center></pre></bdo></b><th id='EwN8q'></th></span></q></dt></tr></i><div id='EwN8q'><tfoot id='EwN8q'></tfoot><dl id='EwN8q'><fieldset id='EwN8q'></fieldset></dl></div>