Questions tagged [ajax]

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

Filter by
Sorted by
Tagged with
6 votes
1 answer
13k views

controller function use with ajax

I have one controller like as below . <?php namespace Drupal\users\Controller; use Drupal\Core\Controller\ControllerBase; class UsersController extends ControllerBase { public function ...
0 votes
1 answer
590 views

How to open jquery dialog on menu click

I would like to open a jquery dialog that asks a question before taking the user to the desired page (ie do some page set-up before they get there). The catch here is that I would like to open the ...
0 votes
2 answers
2k views

Ajax error on node form edit page

I'm trying to ajaxify part of node form. I have a hook_form_alter that adds extra ajax property to a widget of select field. The problem I'm facing is the callback method / function, which is not ...
1 vote
1 answer
2k views

How to hide a form element having a certain class in ajax callback in form?

How can I hide the product using ajax callback . I am trying to implement that using ajax_commands_invoke but it does not work using below code $form['field_product_type_select']['und']['#ajax']= ...
1 vote
1 answer
870 views

Replace textfield value on ajax callback

1) Am i missing something here? it's not replacing the textfield value. 2) Also how do i replace if i have a multiple textfield and multiple button in a form. <?php function test($form, &...
1 vote
1 answer
1k views

AJAX loading of a view on click of a button?

I want to switch between two methods of sorting and displaying items in Views by toggling a button. My exposed filters are in the URL so I want to include the query in the path in order to keep the ...
8 votes
5 answers
15k views

How to add extra arguments/parameters to ajax callback function?

I am using drupal 7. I need to add extra arguments to my ajax callback function. I have five fieldsets in my form, and in all of them same there are same elements, just their IDs are different. For ...
1 vote
1 answer
2k views

Show modal modal message on form success

I have a custom form that submits via AJAX. On form error, i simply return the whole form on my callback function, and the HTML is replaced, but i want it to open a modal dialog on success. What is ...
0 votes
1 answer
1k views

How do I check by default a checkbox from a checkboxes control after an AJAX call

I have the next form which behavior is: When you select an option from select control, different checkbox are load on checkboxes control. When you check/uncheck checkbox a message is showed on the ...
0 votes
4 answers
10k views

"An AJAX HTTP error occurred.HTTP Result Code: 200"

I'm new to Drupal, and I'm working with a Drupal site that someone else wrote. From the admin menu, when I go to Structure -> Pages -> Edit Content -> Gear Menu -> Edit (or Settings), Drupal throws up ...
0 votes
1 answer
804 views

Reset a page with multiple exposed filters

I have a view page which is the main page on my website. It is kind of a search using exposed filters. As I have many exposed filters I installed the module MEFIBS which allows me to split the exposed ...
0 votes
4 answers
3k views

How to run jquery codes before and after ajax call?

I want to create a loading code while the ajax call is not yet complete, AND enable my jquery code after calling the ajax of drupal form. The ajax I'm referring to is the "Add new field/Add more" of ...
0 votes
1 answer
696 views

Why does drupal_session_start() fail after a user clears the cache and logs back in?

I'm writing a document management module which has come pretty far and is almost ready for a final review and release, but I've found a really strange authentication issue that is requiring a gross ...
1 vote
1 answer
544 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. ...
0 votes
2 answers
459 views

Ajax Form Not Working in some Some Regions

I created an ajax based contact form in my module.Then I made a block view for the form. I tried putting that block to several regions. When I put the block to 'Sidebar Second' the form works as ...
2 votes
2 answers
1k views

How to close the overlay after form submission

In order to be able to quickly edit Fullcalendar items, I altered the node edit form of the specific content type so the events are saved with AJAX and the page doesn't have to reload. However, I don'...
1 vote
0 answers
47 views

#ajax not triggering on textfield or any fieldtype other then select

I'm completely clueless about the problem. I have tried to google but have not found any similar issues. My AJAX callbacks work only on the select field type, but I want to trigger ajax on textfield ...
0 votes
1 answer
1k views

How can I add an AJAX callback to a checkbox?

I am using taxonomy manager module I want to add ajax callback to checkbox tree view for checkbox is checked condition but it is not working can some one please suggest me. I have modified the code ...
0 votes
1 answer
748 views

How do I control if an ajax webform has errors?

I have a webform that sends an email upon submission. Ajax is enabled so when I hit submit and there are errors on the form they will show instantly. However if there are no errors I would like to ...
1 vote
1 answer
2k 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
2 answers
883 views

How to do something BEFORE a view is updated via ajax submit button?

I have a view with exposed filters and Ajax activated. I would like to validate my exposed filters values before my view is updated by the submit button. The following code works without Ajax, but ...
0 votes
1 answer
1k views

How to fetch/load a node form using jquery/ajax?

In my previous question, I asked on how to fetch views blocks, now I would like to do the same with the node form but somehow this is the code that almost worked for me: setTimeout(function(){ $('....
0 votes
2 answers
832 views

JQuery Accordion closes unintended when ajax-link from inside gets response

I'm working on a page where a user can click on ajaxified links inside a JQuery-Accordion-Widget. Currently every time a link is clicked and the response is loaded, the accordion gets closed and it ...
2 votes
1 answer
958 views

How to properly add a Commerce Shipping Service option via AJAX during checkout

I have the Payment and Shipping service block in the same checkout pane. I update the Shipping service block with AJAX when selecting a Payment method, as available Shipping services depend on the ...
1 vote
1 answer
1k views

File field upload in modal/dialog

I have a custom content type with file field as one of the fields. For theming/UI purposes I should make this file field as clickable button. And only when user clicks on it, he/she gets modal window ...
2 votes
1 answer
2k views

How to make autocomplete return nid and name?

My question is about textfield autocomplete. I have this code: function my_module_menu(){ $items['my_module/textfield_autocomplete'] = array( 'page callback' => '...
0 votes
1 answer
985 views

How do I create an AJAX form with Add and Remove buttons for multi-value form element without submission button?

I would like to create a custom form with a textfield in which I input some data and it gets saved in the variable table. The form should only contain the Add, Remove, and Add more button to add ...
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 ...
2 votes
1 answer
716 views

Taxonomy term name alias in taxonomy term autocomplete

I'd like to have two or more names for one Term-ID in my custom taxonomy dictionary. As for now I've added a custom field and named it "Synonyms". The field can have multiple values. How can I ...
1 vote
1 answer
2k views

jQuery dialog is duplicated when set on a form that uses AJAX

Im using jQuery dialog on my form. Drupal.behaviors.custom = { attach: function (context, settings) { $('.form-container').once('form-cont', function () { Drupal.custom.modalLinks(); })...
0 votes
1 answer
1k views

AJAX form submit error when sending form to twig in hook_preprocess_page

I have a simple AJAX form that I can't submit when the form is passed from module to the template in hook_preprocess_page. The same form works fine if sent from controller, it's just that the layout ...
2 votes
1 answer
1k views

Form returned from AJAX callback missing JS and CSS

I have a form set up like this: function mymodule_form_{my_form_id}_alter(&$form, &$form_state, $form_id) { $form['actions']['submit'] = array( '#type' => 'submit', '#...
1 vote
1 answer
1k views

AJAX Populated Views Exposed Filter

I'm re-building a travel website and need the trip search form to have the "Arrivals" select populated using AJAX once the departures has been selected to remove any empty search results. I have ...
0 votes
2 answers
2k views

Attach a jQuery function to an AJAX response

I'm trying to attach a jQuery function to an AJAX response. The JavaScript file content is the following. (function($) { $(document).ready(function(){ $('.rembourcement').find( ".button" )....
0 votes
1 answer
774 views

Conditionally enable/disable #autocomplete from client side js

I have a custom search field which searches for a type of content depending on the radio box selected. I have applied autocomplete functionality to the field using hook_form_alter but only want the ...
0 votes
1 answer
616 views

Using 'return' with an ajax callback renders an entire page before my content is loaded

I'm developing a module that uses Openlayers maps and Drupal Commerce. When you click on the map, you should see products that relate to those coordinates of where you click. I have this working ...
1 vote
3 answers
2k views

Dynamic select lists (dependent dropdowns)

I created 2 dependent dropdowns in Drupal 7. In the first dropdown you need to choose the device, in order to see its attributes in the second dropdown. When an option from the first list is ...
2 votes
1 answer
648 views

Ajax error every time open view

i want to create new view but every time i make selection like user, content etc. i got this error An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /dru/...
2 votes
4 answers
4k views

use-ajax class for ajax link not working in dynamic content load

use-ajax class link not working when i load new content using custom ajax code, which has the use-ajax class links. I use normal jquery ajax to load the content because, i have drag and drop ...
0 votes
1 answer
1k views

Trigger ajax callback from input field webform

I have a form build with the webform module. When text is entered in the input box in this case webform component 2 I want it to execute a ajax function and put data in a div. However this is not ...
-2 votes
2 answers
267 views

How can I avoid fields being disabled on AJAX requests (attribute disabled) in Drupal?

I want to make an input not be disabled when I submit an ajax request. I tried reversed variants in these answers, i.e. hanging an "AjaxStart" on the document. $(document).ajaxStart(function(...
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' => ...
0 votes
1 answer
855 views

Sending webpage through email

I've implemented hook_menu and in page callback there is a function in my module which retrieves some records randomly and theme them with theme_table. Now I want a button on the page for sending this ...
0 votes
1 answer
2k views

reCaptcha does not display on modal window(colorbox) webform

I have a webform that I want to add a reCaptcha to. So far I've done everything properly, the webform will display a recaptcha box below the form when viewing the node form. I have a modal window ...
1 vote
1 answer
726 views

Trigger AJAX from a Google Maps Marker

I have a Google map loaded through the Google Maps API with markers generated from node locations. How can I cause content to be loaded via AJAX when one of the markers is clicked. For example, if ...
1 vote
3 answers
7k views

The uploaded file likely exceeded the maximum file size (32 MB) that this server supports on remove image

In my taxonomy terms,when I try to edit a term I got this error : An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (32 MB) that this server supports. ...
2 votes
2 answers
892 views

form_set_error() redirects to raw ajax response page

I have a page with a simple view. Above the view there is a menu link that when clicked loads a node form with a required file field. The form is fetched and loaded using ajax_commands into a div on ...
0 votes
1 answer
1k views

Ajaxy entity reference views filter by entity reference view

I have two content types that share a taxonomy (Size). On content type A, I have an "entity reference" to content type B in the form of a checkbox widget. What I want: On the node creation form, ...
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 ...
8 votes
5 answers
11k views

How do I add a "Add more" button?

I want to show a Add more button that adds an extra text field and the corresponding Remove button. I followed ajax_example_add_more() to achieve this in Drupal 7. For Drupal 8, I tried with the ...

1
2 3 4 5
51