I have a multistep form that uses AJAX and for some reason it breaks for one specific user (customer), even when he tries using different browsers it breaks at the same place. There is a lot of form code so here is my AJAX callback.
function my_form_callback($form, $form_state) { if (!form_get_errors()) { $commands = array(); $commands[] = ajax_command_replace(NULL, drupal_render($form['container'])); $commands[] = ajax_command_invoke(NULL, 'myCustomJSFunction'); return array( '#type' => 'ajax', '#commands' => $commands ); } else { return $form['container']; }
Plenty users complete the form everyday without any problems, but this one user is having a problem with it. He gets to step 3 of the form, but when he clicks a textfield, it triggers AJAX when it shouldn't and an AJAX spinner appears randomly at the bottom of the form, then the JS dialogue box pops up saying there's an error. There is no AJAX added to any fields on the form, only buttons at the bottom of each step.
The weird thing is, when this error happens, if I check the POST data handled by ajax_get_form(), the "form_id", "form_build_id" and all form values are missing so it throws a Invalid form POST data and Undefined index: form_build_id in ajax_get_form() error. What's also weird is the triggering element value is step 1, but he is at step 3 (although he didn't submit step 3, AJAX was triggered by clicking into a field in step 3 for some reason).
All users are anonymous and page caching is turned off. The form uses HTTPS and ctools object caching between steps. I'll take any ideas anyone has about what's going on here. I don't understand why this one person is having a problem but its fine for hundreds of other users.
Comments
It may be a conflict with the
It may be a conflict with the ajax on a different form on the page, that only is there for that user. Sometimes Ajax fields can cross-field pollute.
Contact me to contract me for D7 -> D10/11 migrations.
As always thanks for the
As always thanks for the reply Jaypan. Also as always, every time I post on the forum I seem to discover the problem soon after. In the first step of my form there is a section for people to enter a discount code and that uses AJAX. For some reason it breaks the form two steps later, but now I've replicated the problem I can figure out what's going on. It will be a bug in my code somewhere so I'll mark this as solved.