Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在webform的submit按钮上进行ajax调用?_Ajax_Drupal_Drupal Webform_Submit Button - Fatal编程技术网

如何在webform的submit按钮上进行ajax调用?

如何在webform的submit按钮上进行ajax调用?,ajax,drupal,drupal-webform,submit-button,Ajax,Drupal,Drupal Webform,Submit Button,这是我的代码,我已经在template.php中完成了表单更改。 请给我忠告!我通过webform模块创建了一个webform。我的目标是在不加载页面的情况下提交表单 我的代码如下: function business_form_alter(&$form, &$form_state, $form_id) { if($form_id == 'webform_client_form_7') { $form['actions']['submit']['

这是我的代码,我已经在template.php中完成了表单更改。 请给我忠告!我通过webform模块创建了一个webform。我的目标是在不加载页面的情况下提交表单

我的代码如下:

   function business_form_alter(&$form, &$form_state, $form_id) {
     if($form_id == 'webform_client_form_7') { 
        $form['actions']['submit']['#ajax'] = array(
        'callback' => 'business_webform_js_submit',
        'wrapper' => 'webform-client-form-7',
        'method' => 'replace',
        'effect' => 'fade',
    );
   }

   function business_webform_ajax_submit($form, $form_state) {
       $sid = $form_state['values']['details']['sid'];
      if ($sid) {
        $node = node_load($form_state['values']['details']['nid']);
        $confirmation = array(
          '#type' => 'markup',
          '#markup' => check_markup($node->webform['confirmation'], $node-   >webform['confirmation_format'], '', TRUE),
        );
      return $confirmation;
     }
     else {
       return $form;
     }
  }

您的代码中有一个小错误。
#ajax['callback']
函数的名称与实际函数不同。
您可能希望重命名该函数:

function business_webform_js_submit($form, $form_state)

而且它应该会起作用。

哦!我很抱歉!!我在这里错误地粘贴了代码,我试图给出正确的函数名,但页面仍然加载。谢谢你指出我的错误。