Questions tagged [ajax]

Use it for questions about JavaScript/PHP code to create asynchronous web applications.

Filter by
Sorted by
Tagged with
0
votes
3answers
38 views

How can I send an HTML email from an Ajax callback?

I want to send an email to the user who forget username. I created a functionality that handle with Ajax like send request to controller where I using a query to check whether user exist or not. if ...
0
votes
0answers
31 views

Ajax HtmlCommand not working on form field in a field group

I've added a custom ajax callback to a field that I'm trying to update the value of. The Field I'm updating is inside a field group and instead of updating the field it just empties the html. The form ...
0
votes
0answers
19 views

Can't upload anonymously using webform

I am using varbase 9.0.0-rc1 distribution I have successfully uploaded files using the forms while I am logged in. But anonymously I get the following error: An error occurred while attempting to ...
0
votes
1answer
23 views

Can't submit entityform after ajax callback on select element

I followed the advice from this link and migrated the code populating my ajax into buildForm(), and all is well. Select list is populated by ajax and elements are preserved even after form submit. ...
1
vote
0answers
27 views

Why is my code called again written on build form?

I have a form and i call an API tahta brings huge data on build form. But when i call Ajax on other form elements , the whole code for form(buildForm, constructor ) is called again and again. There ...
1
vote
0answers
19 views

Updating modules creates An AJAX HTTP request terminated abnormally error

Drupal 7.77. I have three modules that need to be updated. Trying to update any one of them results in this error: An AJAX HTTP request terminated abnormally. Debugging information follows. Path: ...
0
votes
1answer
71 views

Ajax Callback to Update Select List not Working

I have defined couple of fields inside my custom entity basefielddefinitions() like so... $fields['product_line'] = BaseFieldDefinition::create('entity_reference')... $fields['product'] = ...
0
votes
0answers
16 views

Passing data-dialog-options and data-dialog-type dynamically to an <a> tag not opening modal

I'm trying to create a dynamic way to open a modal window in drupal. The current structure work like this. <a class="use-ajax" href="/node/810">Testing 1 </a> For that ...
0
votes
0answers
16 views

Show another page in a modal popup

I'm working on a page that will have a couple links on it that need to show another page in a modal popup. I've used class="use-ajax" to accomplish this in the past. However, I'm making ...
0
votes
0answers
26 views

How to upload multiple files in a custom form with Form API [duplicate]

I have a custom form created with Form API. In this form, I have a file field with the type managed_file $form['fichiers_justificatif'] = array( '#type' => 'managed_file', '#title' => '...
0
votes
0answers
20 views

How can I solve form “errors has been found” with custom Ajax dependant field and other Ajax fields?

I've altered a node\edit form where there are two taxonomy refence fields with a select widget. I've added a custom ajax callback on the first field, in order to populate the options of the second one ...
1
vote
1answer
55 views

How to add an Ajax call to an element that already has callback set?

I want to add an ajax callback to a form element inside a form_alter, but it already has 2 callbacks assigned to it. When I review: $form['payment_information']['payment_method']['#ajax']['callback'] ...
0
votes
1answer
30 views

Ajax not getting triggered on change event of selectbox field

I've tried all options to trigger an ajax event on change of a selectbox option inside form alter hook, but nothing works. Below is the sample code $form['field_select_box']['#ajax'] = [ '...
0
votes
0answers
13 views

Send data via Ajax to set entity fields

I'm working on a custom module that works with Ajax to create or update entities. But I'm wondering how I can send data via Ajax to be set in the entity fields. So looking at the example below..how to ...
0
votes
1answer
22 views

How do I display a modal dialog on page load, with working title and dialog options, using OpenModalDialogCommand?

I'm trying to display a modal dialog containing some simple markup on page load. I'm getting the expected markup to load, and the dialog appears. However, the dialog title always displays "...
0
votes
1answer
28 views

Drupal 8 Jquery/Ajax Views Arguments

Setup: I have two contextual filters, service area and ID. In my view if I send {service_area}/{id} i get back the OR query, which is what I want. My question is, when I try to use Jquery to return ...
0
votes
1answer
33 views

How can I rebuild an image field with values in an Ajax callback?

in Drupal 8 I have media form with select box having ajax property and an image field. on select box value change I want to assign specific file to the image field. On form_alter this code work, the ...
0
votes
0answers
18 views

Form element ajax callback errors not printed

Why are my validation errors are not printed when $form['content']['points'] triggers the ajax callback. Form errors are correctly printed if the submit button is pressed. <?php namespace Drupal\...
0
votes
0answers
18 views

How can I call Rest API data from one module to autopopulate on another module?

I have created one module in Drupal 7, in which I have created a form and on submit I have called an Ajax submit callback function which returns a response of a Rest API. Now I want those data from ...
0
votes
0answers
53 views

403 Ajax error when trying to place a block

I am unable to place a block. When I click on 'Place Block' nothing happens. When I check the Chrome console, there is an Ajax Forbidden Error 403. Message below. I have both checked Drupal log ...
0
votes
0answers
10 views

How to use a views ajax pager to only reload the paged main view, not a display-all-items attachment

I have a view page displaying 5 items. The page has a views attachment displaying all items (a leaflet map display with about 200 nodes). The view uses ajax. I find that clicking the views pager ...
0
votes
1answer
53 views

How to redirect in WebformHandler after submitting Ajax form

I'm trying to redirect to a results page after a form that uses Ajax is submitted. The form is a semi long multi step form, so Ajax is enabled for the user experience. I have created a new ...
0
votes
1answer
48 views

Webform alter with ajax submit callback - field values are empty in callback

At this point I'm doubting if I'm doing it the right way, but I'm struggling with an issue: I'm adding an Ajax callback to the form alter of a specific form: function mymodulename_form_alter(&$...
0
votes
0answers
26 views

OpenModalDialogCommand without site configuration permission

I have a custom module in Drupal 8.9.9 to open a form in a modal dialog with OpenModalDialogCommand. The custom_modal.routing.yml file has: custom_modal.open_modal_form: path: '/modal_form/{title}/{...
0
votes
1answer
46 views

Is it possible to call a custom ajax event after removing a file from a managed_file field?

I have a custom form with a managed_file field element. I'd like to call an ajax event after removing a file (clicking the REMOVE button). Is there a way to expand the existing ajax callback for the ...
0
votes
0answers
38 views

How can I set a custom form's element after a managed_file ajax callback?

Scenario: I have a custom form whose first step is to upload a file using a managed_file field element. Then, after this manged file is uploaded I want to rebuild the form using information from the ...
0
votes
1answer
25 views

Is it possible to return a form element AND an ajax response from the same ajax callback function?

I have an ajax callback function that needs to return a form element and also an ajax response. Is it possible to do both? In my callback I need to set and return something like: $form['fid'] = array( ...
0
votes
0answers
30 views

How can I set a field's #value in a custom Form AJAX function?

I have a managed_file field type that has its own build-in #ajax command and I need to add an additional custom command that will populate a hidden field on the form. So far I have a custom managed ...
2
votes
1answer
72 views

#ajax on a managed_file custom form field is not working

I have a custom Drupal 8 form using a managed_file field with an #ajax callback but the ajax callback is never called (example below). I assume that it's because the managed file field type is already ...
0
votes
1answer
63 views

How to load a form/page into a div via AJAX?

I want to open the create user form (/admin/people/create) into a specific div via AJAX. I can currently open such forms into a modal window using the following link format: <a href="/admin/...
1
vote
1answer
59 views

Ajax form add library on callback

I'm having an AJAX form, which on submit fires a callback function where I want to attach my library. Here's the submit button: $form['actions']['submit'] = [ '#type' => 'submit', '#value' =...
0
votes
0answers
37 views

Custom jQuery action on AJAX events

I'm trying to use a custom javascript event when certain actions are performed on my site, specifically things like Webforms, or Node Comments being submitted (both of which are setup to submit via ...
1
vote
2answers
121 views

LogicException: The database connection is not serializable - when I try to open any “gear” on checkout flow page?

So I'm on Commerce -> Configuration -> Orders -> Checkout flows. I'm editing a flow (it's the same with any of them), so i.e. I'm at page: /admin/commerce/config/checkout-flows/manage/...
0
votes
1answer
60 views

Autocomplete field where title is replaced with NID

I'm using Drupal 7 and I have made autocomplete function to be called on a field. File my_module.module: <?php function my_module_menu() { $items = array(); $items['/...
3
votes
1answer
55 views

How to notify user using ->messenger() and ajax

I would like to send a message to the user on an event in the backend without a refresh. I have a 2fa login form that will send a token text. That form has a "did not recieve sms" button/...
0
votes
1answer
48 views

AJAX Modal Form

I created a modal form with Ajax: <?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the ...
0
votes
0answers
17 views

Create and display field dynamically in Ajax

I've created a field dynamically based on a checkbox title I just clicked before, here the code : $form['myfield']['widget']['#ajax'] = [ 'callback' => 'myCallback', 'event' => 'change', '...
1
vote
1answer
70 views

Custom form calls different form in modal, submit/ajax callback of second form not called

I created 2 forms: dms_gift_voucher/src/Form/GiftVoucherForm.php ... /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { .... $...
0
votes
0answers
20 views

Getting intermittent AJAX.js error on a Commerce site when changing product variation dropdown menu [duplicate]

We've been trying to troubleshoot this issue for weeks now without luck and am really hoping someone here can help point us in the right direction. We have a D8/Commerce 2 site with a **very ...
0
votes
2answers
71 views

Populating Select2 with AJAX

I am trying to populate a selec2 field on open with AJAX in Drupal 8. In my hook_form_alter, I have added the following code: $form['#prefix'] = '<div id="form-ajax-wrapper">'; $...
0
votes
0answers
15 views

How to recenter a geolocation google common map in views after an ajax boundary filter execution?

On Drupal 8.97 with all updated modules, I have a View that uses a Geolocation Google Common Map as an attachment. The map acts a boundary filter, but after the filter executes Drupal.ajax(...
2
votes
1answer
77 views

Ajax submission not working for Webform within a node

I am working with a feature where a newsletter subscription form (Webform with ajax submission and confirmation type is inline) should appear in a node. The node would be showing as a popup and the ...
1
vote
1answer
204 views

Show node links in modal buttonpane

I want to show some node fields in buttonpane when I open node in modal. As far as I know, it will automatically show there inputs with type submit and links with class button, but I added class ...
2
votes
2answers
64 views

Changing 2 Elements on Ajax Callback

I have an element $form['elements']['manufacturer']. On change, I want to change $form['elements']['form_factor'] and $form['elements']['model']. Currently I have: $form['elements']['manufacturer']['#...
1
vote
0answers
81 views

CKeditor Media Edit: AJAX HTTP error 500 [closed]

How can I fix the AJAX HTTP error 500 to make the "Edit media" button in the body of the CKeditor work? I am trying to use the "Edit media" function to edit an image, which was ...
5
votes
1answer
226 views

Error handling with Drupal.ajax()

First I am not very good in JavaScript so maybe I do not know some very basics... I apologize in advance. I created a form where I want to save every change in single fields directly without the need ...
0
votes
1answer
46 views

Ajax callback on Views exposed form filter

I'm trying to add an #ajax callback method to my views exposed form filter select box. But it seems the form have some issues with the callback. My code is pretty simple /** * Implements ...
2
votes
1answer
104 views

How to attach variables to drupalSettings with ajax?

With the page attachments function, I can easily attach a library or some variables to drupalSettings. Now however, I want to replace some HTML code with ajax AND attach some variables to ...
0
votes
0answers
36 views

Load more AJAX with entity query

I want to set load more functionality using entity query, i have load all user data using entity query and set range condition and sorting condition, my scenario is i want to load all the data in ...
-2
votes
2answers
83 views

Sending data to a controller with AJAX POST

I am using AJAX to send request to controller, but the data is sent with the GET method. I want the request send with the POST method. The following is the code I used. var table_url = '/table-data'+...

1
2 3 4 5
49