When I got an AJAX Webform with submission settings "redirect" on a certail page, Internet Explorer won't redirect. All other browsers work just fine.

What happens?
Well, on a successful submit, the AJAX request loads the file ajax_responder.js from CTools and then invokes some Drupal "commands". The last command is "redirect" which gets added to the DOM by said ajax_responder.js.

However, in Internet Explorer, the Block to add these commands to the prototype is NOT executed, because it's wrapped in a jQuery function object:

// Hide these in a ready to ensure that Drupal.ajax is set up first.
$(function() {
Drupal.ajax.prototype.commands.attr = function(ajax, data, status) {
$(data.selector).attr(data.name, data.value);
};
.....

What was wrong (or however what fixed the problem) was not to execute it as a jQuery function, but add it as a Drupal behaviour and let Drupal do the work:

Drupal.behaviors.ctools_add_ajax_responder_commands = {
attach:function() {
Drupal.ajax.prototype.commands.attr = function(ajax, data, status) {
$(data.selector).attr(data.name, data.value);
};
.....

You may find my patch in comment #2. Please take a look at it and comment wether this is the proper solution for that case or not.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fmueller_previon created an issue. See original summary.

florianmuellerCH’s picture

florianmuellerCH’s picture

Issue summary: View changes
MustangGB’s picture

Title: AJAX commands redirect, reload & submit not added correctly to prototype in Internet Explorer » AJAX commands redirect, reload & submit not added correctly to prototype in Internet Explorer and jQuery3
Version: 7.x-1.9 » 7.x-1.x-dev

This fixed ajax reload not working after enabling jQuery3.

I won't RTBC as I've not looked into it enough to know if this is the best fix, i.e. what the consequences/downsides are.

Also your patch is malformed.

But good job, it's working for me for now.

skylord’s picture

Suffered from the same issue in Chrome with jQuery 1.10 from jquery_update. Misteriously all worked fine for admin user and not for usual one - have no time to investigate but that patch helped. Thanks!

joelpittet’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Looks like this needs a reroll. At first glance this looks like it was going in the right direction but need to look closer after it's rerolled.

mohit1604’s picture

Issue tags: -Needs reroll
FileSize
1.71 KB

This should work fine :)

mohit1604’s picture

Status: Needs work » Needs review
travis-bradbury’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Ajax, -internet explorer, -submit, -ajax webform form submit

#7 solves my problem of ctools ajax redirect not working after updating to jQuery 3.3.1.

Cleanup up tags per issue tag guidelines.

rivimey’s picture

torotil’s picture

Title: AJAX commands redirect, reload & submit not added correctly to prototype in Internet Explorer and jQuery3 » AJAX commands redirect, reload & submit not added correctly to prototype

I have the same problem with Chromium 73 and jQuery 1.7.2: The ajax commands are not defined after the ajax-responder.js is loaded. The patch solves the issue for me as well.

This is definitely not limited to jQuery 3 or Internet Explorer. I made the issue title less specific.

MustangGB’s picture

Status: Reviewed & tested by the community » Needs work

Patch works, but there is an unnecessary change to the comment:

- // Hide these in a ready to ensure that Drupal.ajax is set up first.
+ // Hide these in a ready to ensure that Drupal.ajax is set up first.+
shubham.prakash’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
1.62 KB

Fixed the commented line as mentioned in #12.

MustangGB’s picture

Awesome!

joelpittet’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: #3031732: Plan for CTools 7.x-1.16 release » #3178513: Plan for CTools 7.x-1.17 release

Minor code standard spacing around attached on commit. Thanks for fixing this up, it's now on the dev branch which will be released likely today.

joelpittet’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: #3031732: Plan for CTools 7.x-1.16 release » #3178513: Plan for CTools 7.x-1.17 release
joelpittet’s picture

Status: Fixed » Closed (fixed)

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