Questions tagged [ajax]
Use it for questions about JavaScript/PHP code to create asynchronous web applications.
891
questions with no upvoted or accepted answers
6
votes
0
answers
116
views
How to modify auto populate field value?
I m Stuck in two situation where I have to modify value of one field depending on another field selection.
First situation is like I have two field
Region (Node reference) - the widget type is ...
5
votes
2
answers
2k
views
Using the Batch API with AJAX?
I have been trying to figure out how to use the Batch API in an overlay via AJAX, but are not sure that's possible at all? - As far as I can see the batch API, when javascript is enabled, calls the ...
4
votes
0
answers
1k
views
Loading a form in dialog/modal returns an error
I have a form with a submit button binded to an AJAX callback that opens up a modal with another AJAX form. The modal dialog opens with the form, but the AJAX submit in that modal form isn't ...
4
votes
1
answer
982
views
Prevent dual submit on form submission
I've got a form that submits via AJAX and in the callback I need to rebuild certain parts of the page to reflect the newly submitted data. One of these parts is the form, which I need to clear all ...
4
votes
0
answers
1k
views
Push data to dataLayer on Webform Ajax submit
I'm using the Webform Ajax module to ajaxify my Webform and I need to push some data to the dataLayer to use with Google Tag Manager after a successful submit.
Like:
dataLayer.push({
'event': '...
4
votes
0
answers
503
views
View exposed filter block no alter form with ajax
I am trying to filter out the no results items in my exposed filters. (I know i can use selective filters, but in this case i can't use them).
So i alter the filters with form_alter, check which ...
4
votes
2
answers
4k
views
How to trigger a form and pass variables to $form_state with jQuery?
What is the way to trigger a Drupal form via JavaScript, and pass new values to $form_state while doing so?
I have a main form, which has an element that triggers a jQuery UI dialog with a form in it. ...
4
votes
1
answer
396
views
Append Fields to node form by ajax call
I have a node form with some fields, now I want to append some more fields to it on an ajax callback. in the ajax page I have rendered the new form elements with drupal_render function
My problem is ...
4
votes
2
answers
2k
views
Load an AJAX submission enabled webform using another AJAX call
I am using Javascript/AJAX to call a path defined in a custom module which loads existing node content for display. i.e. you are at:
/custom/path
and it makes an AJAX request to /custom/content ...
3
votes
0
answers
759
views
How to filter autocomplete on a dependent field?
Goal - How to filter autocomplete based on a related field? In this domain, an organisation is selected and then the autocomplete should only allow items created by that organisation to be selected.
...
3
votes
0
answers
1k
views
Drupal Ajax pager
Am looking for a solution to implement $form['pager'] = ['#type' => 'pager']; into AJAX callback (without reloading the page). I have read alot of posts concluding there is no a drupal way to do this ...
3
votes
0
answers
872
views
Pass Exposed Filter in Url / Link to Views page with AJAX
I have a Views with page display of field sets on url
www.foobar.com/specialview
Contains a number of exposed filters with AJAX. - works great.
One of those fields I'm 'Rewrite Results' to a custom ...
3
votes
2
answers
818
views
Form submission in modal is throwing an error
I have a Form which on submit calls another form via ajax and embeds it into a modal popup (Drupal8 standard) and when I click on submit of that modal form , I get a Drupal ajax error (I think it's ...
3
votes
1
answer
1k
views
How to do push data to datalayer after Ajax callback?
I have a view with many elements and use views load more -> view using views load.
Modules:
Views Load More.
dataLayer.
Is it possible send datalayer event after load elements with AJAX?
I am ...
3
votes
0
answers
366
views
Image upload replaced modal
I have a form that has text_format form element with CKEditor in it and it has the image button in toolbar.
This form is being displayed via modal. When I click on the image the image upload/...
3
votes
1
answer
360
views
What to return from form AJAX Callback
I used the examples found here as my AJAX guide.
I have a custom form field
$form['elements']['refunded']
which is entirely defined in a single line as an array. My AJAX DIV's and callbacks work ...
3
votes
3
answers
2k
views
Dynamically add input field using #ajax
As the question says, im not clear on how to go about adding new input fields depending on values of certain fields in the form.
I got as far as setting a callback and a wrapper, but i just can't ...
3
votes
1
answer
545
views
How to add javascript after form was validated with ajax callback?
I created a simple form.
How could I add JavaScript commands after form was validated? Why is it so hard do this?
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'submit',
'#...
3
votes
0
answers
506
views
How to populate a managed file field with ajax
Problem
I have a large form with a select field tied to an ajax call. When an option is selected a large chunk of the form is rebuilt and a number of fields re-populate.
All the fields pre-populate ...
3
votes
0
answers
716
views
How to pipe file uploads to subdomain?
I've got a Drupal 7 site on Apache and Varnish, sitting behind the CloudFlare CDN. Everythin on mysite.com goes through cloudflare... I also have a "direct access" subdomain set up at direct.mysite....
3
votes
0
answers
190
views
Disable form altering for admin pages on Bootstrap 3
My default theme is Bootstrap but I use Shiny theme as admin theme. Bootstrap theme alters the forms and fields.
And I use Hierarchical Select module, there is a dropbox for multiselection and the ...
3
votes
0
answers
251
views
Drupal 7 AJAX error when running batch with Internet Explorer
I'm getting an AJAX error when running any batch with Internet Explorer 8, 9 and 10.
This error occures when I'm using "feeds" module, "views send" module or when I delete a user.
For example, when ...
3
votes
1
answer
1k
views
how to change the size of an exposed filter autocomplete form?
the source shows:
<input id="edit-field-location-taxonomize-terms-tid" class="form-text form-autocomplete ctools-auto-submit-processed" type="text" maxlength="128" size="60" value="Germany" name="...
3
votes
1
answer
2k
views
How to load block on link click with AJAX framework?
I have tried in my custom module:
Declaring a path for Ajax callback
function custom_menu() {
$items['ajax-block/%'] = array(
'title' => 'Ajax test callback',
'type' => ...
3
votes
1
answer
2k
views
Is there a way to load content of each tab in the view using AJAX?
I've created View to display my content and I'm using Quicktabs module https://drupal.org/project/quicktabs to format the output of this view into the tabs.
Is there a way to load content of each ...
3
votes
1
answer
614
views
Autocomplete term widget (tagging) - Insert as child
Is there a way to insert taxonomy terms as child of a parent term with the auto complete term widget?
I have found several modules such as "Content Taxonomy" or "Hierarchical Term Reference ...
3
votes
1
answer
685
views
Ajax webform: refresh page on a successful submission
I am using the ajax webform, because I don't want the page to be reloaded when the user doesn't enter everything correctly because my form slides in and reloading just causes it to disappear and you ...
3
votes
2
answers
2k
views
Add javascript to returned form after ajax validation
I've built a form with the form API, and it's submitting via ajax via this type of thing:
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'submit',
'#ajax' => array(
'...
3
votes
0
answers
2k
views
Views AJAX pager is not working for custom theme
I am using a custom theme for my Drupal site. Here I have created views with page displays, Kept AJAX pager 'on'. When I click on next the pager keeps on loading.
In firebug I found the following ...
3
votes
1
answer
6k
views
How do I add/remove form fields dynamically?
i have form build in standard like:
public function getFormId() { }
public function buildForm(array $form, FormStateInterface $form_state) { }
public function validateForm(array &$form, ...
2
votes
0
answers
437
views
Refresh a form with Ajax after closing a Dialog
So I have a custom form in which I display a list of entities.
Below that list, I added an “Add More” link which opens a Dialog.
When I close (or submit) the Dialog, I want the list of entities to be ...
2
votes
0
answers
291
views
Refresh view using ajax with parameters
I use this code to refresh a view, but It reloads the view ignoring neither page number nor filters.
$('.view-id-name').trigger('RefreshView');
How could I pass parameters (page number, query filters,...
2
votes
1
answer
926
views
Custom Submit Callback only triggering when Form is Valid when in Dialog
I'm trying to create a node in a dialog with the following link:
Enter the title of a registration form or <a class="use-ajax"
data-dialog-options="{"width":...
2
votes
1
answer
547
views
CSRF token is not varying in Ajax callback while submitting form
I have a form with ajax callback as following , on each submit token is not varying , it remains constant for all submit .
wall.routing.yml
wall.commentform:
path: '/commentform'
defaults:
...
2
votes
0
answers
656
views
Multiple dependent form fields
I'm building a form following the ajax examples module, specifically the dependent dropdown form.
I've tried the same approach as the example, calling a static function to retrieve the options for the ...
2
votes
0
answers
143
views
Drupal Form code is called again on every ajax Call?
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 ...
2
votes
0
answers
335
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: ...
2
votes
0
answers
199
views
Close a content type form in a modal popup and avoid redirection to the created node page
I have a content type reference on a user page. On clicking the add content button it opens as modal popup with the node form. Post filling the form on submission the page redirects and goes to the ...
2
votes
0
answers
280
views
Return and display the same form in Ajax Response
Summary:
I have an AJAX form. When I press the submit button, I want to build the same form, and return it for display again.
It's working fine if I display another form, but not with the same form.
...
2
votes
0
answers
130
views
Different 'Items Per Page' on different pagination while using 'views_infinite_scroll' module
I am using views_infinite_scroll module to load more nodes with 10 nodes on every click and views AJAX is enabled.
I am working on a requirement like as, I have 100 total nodes and getting in a view ...
2
votes
0
answers
321
views
Validate a form multiple times
Is it normal that my validateForm method in Form API doesn't trigger second time i call it?
And if yes, how do i trigger it multiple times? I've got multistep form and i want to validate each step ...
2
votes
0
answers
851
views
How to bypass "allowed values" validation for a select field (list_string)?
At the user account form, I've created two select fields (of type list_string) for state and city.
The state field has a list of states for its allowed values config, and the city field has no values ...
2
votes
0
answers
815
views
scrolling after posting drupal ajax form
I am working on an existing site which has a Drupal 8 multi-step form which uses Ajax
Upon submitting the form (on the final step) the page scrolls to the top where a thank you message has been ...
2
votes
0
answers
26
views
How can I prevent the theming layer being loaded for JSON requests?
I can verify that views-exposed-filter.tpl.php is being loaded for basic JSON endpoints that don't re-render any form fields: My autocomplete - /search_api_autocomplete/...
2
votes
1
answer
2k
views
Autocomplete textfield displays value when selected and not label
I have a textfield autocomplete field that shows a list of full user names and email addresses as designed but when a user is selected, the user id is displayed in the field; not the name and email ...
2
votes
0
answers
3k
views
How to properly cache AJAX request responses with the controller from my custom module?
I've got an drupal 8 project with an custom module. There I have an controller which returns specific data we need there. In my js file, I have 7 AJAX requests which are called when someone visits the ...
2
votes
0
answers
605
views
Is it possible to avoid div wrapper when I use HtmlCommand or ReplaceCommand?
I'm working on a D8 project and I have some ajax callbacks where I use ReplaceCommand and HtmlCommand.
It works fine but adds an extra div to my html.
For example I do :
$response->addCommand(...
2
votes
0
answers
514
views
Ajax callback (not triggered) on content added by ajax
The only post I've found about this question is sadly unanswered, so here's my situation.
I have a custom form that I made in MyModule. On the send button, I set an ajax call that loads a list of ...
2
votes
1
answer
1k
views
Reset button for an AJAX form
How do i programatically reset the values of an AJAX submitted form for Drupal 8? I Want to reset them with an AJAX callback. Here is my current callback. It works because i'm forcing the values to ...
2
votes
1
answer
2k
views
Upload a file by Ajax without submitting the form
I want to upload a file by Ajax (without submitting the form) than process in backend, and clear the field to allow to add another file. Is it possible with Drupal 8? Can anyone provide an example?
I ...