After updating this module, the browser give this error:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience drupal

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BartGysens created an issue. See original summary.

vinmassaro’s picture

I used git bisect to trace this back to commit 31f4bd14c9c8646709d53ea7975a881fa78d6741 which is from this issue #2858991: Add jQuery Form 4 for jQuery 1.7+. Downgrading to 7.x-3.0-alpha3 fixes this problem.

markhalliwell’s picture

Version: 7.x-3.0-alpha4 » 7.x-3.x-dev
Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)
Issue tags: -ajax error

"Synchronous XMLHttpRequest on the main thread" isn't an error and doesn't cause something to stop working.

I need a real JS error.

vinmassaro’s picture

@markcarver: It appears to be the switch from jQuery Form 3.x to 4.x. Reverting to jquery_update 7.x-3.0-alpha3 makes it work again.

There is no error logged in the browser console and the ajax request gets a 200 response back when clicking 'add another'. Happy to help debug this if you can provide additional steps (I pinged you on IRC) or I can provide the steps to reproduce. Thanks.

markhalliwell’s picture

I'd appreciate it, I'm kind of busy at the moment.

The funny thing is, #2604976: Ajax error during file upload using jQuery 1.5 for admin theme is basically the same issue, but for jQuery 1.5.

That being said, I tested that issue with jQuery Form 4 and it worked just fine.

My guess is that the contrib JS is the real "culprit".

vinmassaro’s picture

Using 7.x-3.0-alpha4, this is logged in watchog when adding another field collection item:

Notice: Undefined index: #ajax in ajax_form_callback() (line 395 of /sandbox/d7/includes/ajax.inc).

Dumping $form_state before line 395 in ajax.inc shows $form_state['triggering_element']['#ajax'] does not exist, as expected based on the PHP notice. If I downgrade to 7.x-3.0-alpha3, dumping $form_state['triggering_element]['#ajax'] shows:

Array
(
    [callback] => field_add_more_js
    [wrapper] => field-content-listing-add-more-wrapper--2
    [effect] => fade
)

I also noticed that with 7.x-3.0-alpha4, the parent entity (node in this case) is prematurely saved every time you try to add another field collection item. Hope this is helpful. Let me know if there is other debug info I can provide. FWIW I spun up an instance on simplytest.me with latest Field Collection and jQuery Update, and creating a simple field collection with 1 field that had unlimited values on the node _did not_ cause this behavior, and worked fine, so I'm not sure yet what conditions this happens under.

markhalliwell’s picture

Title: After update; multi value fields with "add another" no longer work » jQuery Form 4 Breaks Everything
Status: Postponed (maintainer needs more info) » Active
anuragsharmam’s picture

Priority: Normal » Major

@markcarver

When I try to add another item from the backend, the ajax call success but the fields not loaded in the form. In watchdog, i could see this error
Notice: Undefined index: #ajax in ajax_form_callback() (line 395 of /mnt/www/html/tns12pp93tpkyy/docroot/includes/ajax.inc).

While reverting the module to 7.x-3.0-alpha3 all works fine. So it seems that jquery form 4 is not supporting somewhere to jquery 1.7 version specifically. Apart it seems to break all ajax calls.

markhalliwell’s picture

Priority: Major » Critical

@anuragsharmam, it would be far more helpful to read an issue and then provide additional information rather than duplicate the same comments as others before you.

Also, this is really a critical issue because it breaks everything.

I'm wondering if, perhaps, jQuery Form 4 should actually be jQuery 1.8+ or maybe even 1.9+. jQuery Form 3 said it was 1.5+ compatible, but #2604976: Ajax error during file upload using jQuery 1.5 for admin theme seems to have proved that wrong (at least in Drupal).

I'll attempt to provide some patches shortly to see if either of these work.

markhalliwell’s picture

Status: Active » Needs review
FileSize
952 bytes
952 bytes

Please make sure to test the following patches for each jQuery version 1.7+.

sergei_brill’s picture

I did research the bug today and found that if the value of clicked submit element contains space the form works incorrectly. It fails in function _form_element_triggered_scripted_submission in form.inc in the second condition.
Problem is that it sends encoded value of submit input. So, instead of 'Add new node' $_POST contains 'Add+new+node'.
Switching to jQuery of version 1.6 (which uses jQuery form 3) fixes problem.
I don't know is it a bug of jQuery form 4 or just incompatibility of Drupal ajax system and jQuery form 4, but think that jquery form 4 can't be used by default when you switch jQuery version to higher. jQuery form 3 is old, but it was used long time before without a problem (at least on my sites).
If you really want to bring jQuery form 4 with your module, it is better to add separate switcher form jQuery form version on configuration form and add notification that 4th version can break ajaxified forms.

NancyDru’s picture

Status: Needs review » Needs work

I used the 1.9 patch in #10 and it still fails. My site is a US government site; FISMA standards require jQuery 1.10 or higher for security. Alpha4 breaks the "Add another" button on Field Collections; alpha3 works as expected. There needs to be a note on the project page warning that Alpha4 is seriously flawed and should not be used.

MariskaTh’s picture

I had the same problem. Notes were duplicated when I only wanted to update them. I couldn't change certain things to nodes that were already created.

I degraded to alpha 3 and now everything is okay again.

I'm very happy I found this tread.

Best regards,
Mariska.

markhalliwell’s picture

There needs to be a note on the project page warning that Alpha4 is seriously flawed and should not be used.

That's why the releases have been tagged with alpha, which inherently implies that it is not stable...

---

It sounds like the real issue is parameter string conversions as was semi-described/buried in #11:

Problem is that it sends encoded value of submit input. So, instead of 'Add new node' $_POST contains 'Add+new+node'.

markhalliwell’s picture

Title: jQuery Form 4 Breaks Everything » Add jQuery Form 4 when it doesn't break everything
Category: Bug report » Feature request
Priority: Critical » Normal
Status: Needs work » Active

Ok. I've stepped through all the code (drupal, jquery_update and jquery.form) and it is, in fact, a regression in jQuery Form.

I've submitted a PR with them there: https://github.com/jquery-form/form/pull/521

I'll go ahead and revert #2858991: Add jQuery Form 4 for jQuery 1.7+ for now and leave this open to re-add once it's been resolved and released on their end.

  • markcarver committed 2028ddd on 7.x-3.x
    Revert "Issue #2858991 by markcarver: Add jQuery Form 4 for jQuery 1.7...
markhalliwell’s picture

kevindb’s picture

jQuery Form has been updated to 4.2.1 with fix from markcarver.

Form v4 is compatible with jQuery 1.7 through 1.11. Form v4.2.0 added support for jQuery 1.12+ and jQuery 2 and 3.

markhalliwell’s picture

Title: Add jQuery Form 4 when it doesn't break everything » Re-add jQuery Form 4.2.1
Status: Active » Needs work

Well that was quick :D Thanks @kmorri36!

I'll revert the revert, update to latest release and the release a new alpha :D

  • markcarver committed 2d623f1 on 7.x-3.x
    Issue #2860158 by markcarver, vinmassaro, BartGysens, sergei_brill: Re-...
markhalliwell’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

AaronELBorg’s picture

Wow.

I was having the issue of "Notice: Undefined index: #ajax in ajax_form_callback() (line 395 of /var/www/html..." after trying to ajax-remove a field collection in a node that had over 350 field collections within it. (That should have been my first clue. WAY TOO MANY field collections due to an import gone awry... but that's another story.)

After the update to the latest dev and changing the jquery version for my admin theme I was STILL getting the error and therefore, of course, no save was happening. So after looking in my server logs, inside error.log I noticed I was getting a message of "PHP Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini."

So I got straight-up crazy and (until I fix this import script) raised the max_input_vars from 1000 to 2500.

My ajax request to remove the field collection item seems to work now. (i.e. The gui updates properly.)

I'm posting this in hopes that it saves someone else some time.