In my site I have problem "Invalid POST data" on ajax form very often.
In code I see, what this happend in function that return FALSE in file

function form_get_cache($form_build_id, &$form_state)
$cached = cache_get('form_' . $form_build_id, 'cache_form')

It can return cache in 90% or return FALSE in near 10% of form fillings
I can't simulate and undestand situation whan this function return FALSE. And can't decide problem.
1 lost form = 1 lost client. It very bad for Company and my practic with Drupal.

Where I must look to find solution?!!!


dcam’s picture

Assigned:parashutiki» Unassigned
Category:Bug report» Support request
Priority:Critical» Normal
Status:Active» Fixed

I suspect that you're talking about anonymous users trying to use an AJAX form with page caching enabled for anonymous users, in which case that is a well-documented issue. Check out #1694574: drupal_process_form() deletes cached form + form_state despite still needed for later POSTs with enabled page caching. If that is the issue you're experiencing, then please post any further communication about the issue in that ticket.

parashutiki’s picture

Thank you for reply dcam!
With this situation I have encountered: core caching feature for anonymous users switched on
In my site I disabled this featutre a long time ago.
I have installed module AuthCache for performance.

Why I am interested in this?
Today I have more and more breaked forms.
I explored array $form_state in breaked forms.
All fields are filed but form_build_id field is missing
Notice: Undefined index: form_build_id in ajax_get_form() (string 321 in file /var/www/clients/client1/web1/web/includes/

parashutiki’s picture

Status:Fixed» Active
parashutiki’s picture

Status:Active» Needs work
dcam’s picture

Title:Where I must look to find solution with "Invalid POST data" ?!!!» Invalid POST data error on AJAX form
Status:Needs work» Active

Ok, well you haven't supplied enough information for anyone to be able to give you any real support. Please list the modules you have enabled. Knowing that you have AuthCache enabled could have been a valuable piece of information. What forms are experiencing the problem. One form? A few of them? All forms? What modules are creating the affected forms?

The gist of that other issue is that a form gets cached and the cached version is served to two or more separate users. One user submits the form, then when the other user submits it the form_build_id is no longer in the cache and the error is produced. Although you're not using core's anonymous page caching, it seems possible to me that another cache system could experience the same problem. What type of cache are you using with AuthCache? Have you tried disabling AuthCache to see if that fixes the problem?

parashutiki’s picture

dcam, thanks for help.
Problem was in ceaching.
I make many changes. And I mean problem was in function drupal_render. Or may be not I am not shure 100%.
Now I have Invalid POST data but if I watch to $form_state array I see always similar values. I mean it not serious.

 * Implements hook_block_info().
function custom_module_block_info() {
  $blocks['cmth'] = array(
    'info' => '...',
    'status' => TRUE,
    'region' => 'content',
    'visibility' => BLOCK_VISIBILITY_LISTED,
    'pages' => 'node/331',
    'cache' => DRUPAL_NO_CACHE,
  return $blocks;

 * Implements hook_block_view().
function custom_module_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'cmth':
      $block['title'] = '...';
      $block['content'] = HERE_WAS_FUNCTION_drupal_render_WHAT_I_REMOVED drupal_get_form('custom_module_form_home');
  return $block;