Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7760859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:00:04+00:00 2026-06-01T14:00:04+00:00

I’m working on a block module and would like to perform ajax operations on

  • 0

I’m working on a block module and would like to perform ajax operations on its configuration forms when a file is uploaded via a managed_file field.

So when the managed_file hidden field change (once the file is successfully uploaded), there is an ajax callback. The ajax is called like this:

function updateVideo($action){
(function ($) {
    $.ajax({
        url: '/block_video/update_video', // drupal menu path
        dataType: 'json',
        type: 'POST',
        data: { 'action' : $action },
        success: function(data){
            // @ TODO
        }
    });
})(jQuery);
}

The drupal path registered above (/block_video/update_video) call a function where I would like to retrieve the block configuration $form_state variable with its current state (not initial). Is it possible to see the current block configuration form states without using javascript directly and without a calling a page refresh?

It would be way simpler for me to just use the ‘#ajax’ property on the managed_file, but it doesn’t have it. So I added the ajax callback above by waiting for a value change on the managed_file hidden element and this part is working (using the method described here http://forum.jquery.com/topic/adding-a-change-event-on-a-hidden-field).

I should be able to retrieve the $form_state in my custom ajax callback. I would like to do it the way it’s done with the FAPI [#ajax][callback] (both $form & $form_state are passed to the callback parameters – I only need the current $form_state passed to my callback or accessed in it), I couldn’t figure how it’s done by Drupal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:00:06+00:00Added an answer on June 1, 2026 at 2:00 pm

    Alright, I fixed it soon after asking it so here the answer :
    I didn’t find any solution to retrieve form_states outside the #ajax callback, so when the hidden field state change, I get the current form state directly from a pure jQuery ajax function.

    Off topic but kind of related : I managed others form_states inside the usual FAPI #ajax php callback, I needed to call some custom js right after, so with the method below you can trigger a second ajax callback or just a function. It’s done this way :

      // Code inside the FAPI #ajax callback :
      // Trigger the function $.fn.ajaxTrigger defined in my js file.
      $commands[] = ajax_command_invoke(NULL, 'ajaxTrigger');
      return array(
        '#type' => 'ajax',
        '#commands' => $commands,
      );
    

    With this command you can call any javascript function from a Drupal 7 #ajax callback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.