Questions tagged [drupal-ajax]

Drupal AJAX refers to the AJAX implementation used from Drupal.

In Drupal 6, the support for AJAX was limited to the #ahah form API property. Drupal 7 has an extended support for AJAX that starts from the #ajax form API property, and continues with a group of functions that are part of the Drupal 7 Ajax framework.

42 questions
5
votes
1 answer

Issue for a "two dimentionnal 'add another item' " with FormStateInterface::getTriggeringElement()

I'm learning drupal 8. I want create a page who contain a 'two dimensionnal' 'add another item' form. My code works well almost, but I have a strange behavior when I add rooms to a house (there is a strange value in my debug logs from the…
spacecodeur
  • 2,206
  • 7
  • 35
  • 71
4
votes
1 answer

drupal 8 Calling a JavaScript function after an #AJAX event

I want that js script running after doing the ajax action. For example, its work for Drupal 7: Drupal.behaviors.events = { attach: function(context, settings) { $('#example').bind('ajaxSuccess', function(data, status, xhr) { >>code…
Jerzy Stuhr
  • 63
  • 2
  • 7
3
votes
1 answer

Is it possible to use a template file to return HTML for an AJAX call?

A site I'm working on uses AJAX extensively to lazy load page data and to do Twitter style paging. I'd really like to be able to render the HTML via a template file as it will be easier to code and maintain than building an HTML string in a PHP…
SomethingOn
  • 9,813
  • 17
  • 68
  • 107
3
votes
1 answer

Drupal-8 Modal does not handle errors on login

I have used 'use-ajax' class to render login form in a modal. I want to handle validation errors on same modal without closing it. On successful login it is redirecting correctly, but when an error occurs it closes modal and redirecting to login…
Sandeep Sharma
  • 867
  • 7
  • 17
3
votes
2 answers

Drupal 7 Forms API - AJAX Forms error: An illegal choice has been detected. Please contact the site administrator

I have a form set up where a users selects an item from a drop down. Once that item is selected another drop down is populated. Then depending on the value that is selected from the second drop down a fieldset may or may not be shown. If the field…
LoneWolfPR
  • 3,978
  • 12
  • 48
  • 84
3
votes
3 answers

How to submit ajax drupal form using javascript

first of all, i've tried Amar Ravikumar solution there, but it still doesn't work. I have this piece of code : $form['button'] = array( '#type' => "button", '#id' => "mymoduleAjaxButton", '#value' => t("Process"), '#ajax' => array( …
GeoffreyB
  • 1,791
  • 4
  • 20
  • 36
2
votes
4 answers

AJAX in Drupal Forms?

How would you go about constructing a step by step form that uses AJAX through Drupal to pull the next form step? For example, Step 1: I like Baseball I don't like Baseball. When that person clicks on either Like or Don't Like, I want to use…
Kevin
  • 13,153
  • 11
  • 60
  • 87
1
vote
2 answers

Drupal 7, how to dynamically populate a field based on the summation of two other fields?

I have two fields $form["field_num_males"] $form["field_num_females"] I need to dynamically populate the field $form["field_gender_total"] with the summation of them, before the submission (AJAX). How can this be done with Drupal 7? Thanks!
perpetual_dream
  • 1,046
  • 5
  • 18
  • 51
1
vote
1 answer

Ajax and hook_form_alter

I'm getting a "The value you selected is not a valid choice." error for an Ajax modified field when I submit a custom altered node/add form. An "Illegal choice error is also written to the log. This a Drupal 9 version of an app that I developed…
1
vote
1 answer

How to detect Drupal (8) views ajax call start (with JS only)

I'm trying to do some custom UI tweaks while a view is being reloaded with ajax. I can find ways to trigger events when the ajaxcall is complete but I can't seem to find something similar for when the ajaxcall is started. The view gets updated with…
1
vote
0 answers

Drupal Multiupload Filefield Widget conflict with mutiselect ajax dropdown

I have created a multiupload field in my node using Multiupload Filefield Widget. I am using the code below to alter the default node form. There is an ajax based dependent dropdown field in the form i.e city dependent on country.When I select a…
1
vote
1 answer

Drupal AJAX HTTP error occurred During Installation

I am trying to install Drupal using IIS 7 on Windows and it gets pretty far in the installation before it fails with the below error message. I always end up having to go back into Windows Services and start the MySQL service back up because it…
Adam
  • 4,590
  • 10
  • 51
  • 84
1
vote
2 answers

Drupal 7 get node id in AJAX

i'm submitting a form to create node using ajax. I can able to create a node using drupal_get_form('node_form', $node) but i need the node id in response. Can anyone help me out to get the node id in ajax response after creating the node.
Mohanraj
  • 97
  • 2
  • 12
1
vote
2 answers

drupal 7 ajax form rebuild form to change form_state value

I have one drupal form, i want it works as "add one more": there is one button at the end of the form, when click it, another form will append to it. Here is part of my code: function add_passenger_form($form, &$form_state){ …
user3210341
  • 77
  • 1
  • 2
  • 14
1
vote
1 answer

drupal 7 module js ajax get file path

i have one module: wego, and i want to use ajax in wego.js which is located in wego/js/wego.js. The ajax needs send get request to get_data.php which is located in wego/get_data.php. My server setting is test.drupal.com. Here is my…
user3210341
  • 77
  • 1
  • 2
  • 14
1
2 3