# Problem with gform\_confirmation

**URL:** <https://community.gravityforms.com/t/problem-with-gform-confirmation/14416>\
**Category:** Get Help\
**Tags:** custom, gform\_confirmation\_loaded\
**Created:** [February 10, 2023, 11:59am UTC](https://community.gravityforms.com/t/problem-with-gform-confirmation/14416 "2023-02-10T11:59:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user636925d834fb5434](https://avatars.discourse-cdn.com/v4/letter/u/e99b99/32.png) [@user636925d834fb5434](https://community.gravityforms.com/u/user636925d834fb5434)\
**Post date:** [February 10, 2023, 11:59am UTC](https://community.gravityforms.com/t/problem-with-gform-confirmation/14416/1 "2023-02-10T11:59:35Z")

</div>

Hello,

I have a problem with a use case. I need to execute JS code after my forms are submitted and it has to work with confirmation messages and redirections. With confirmation messages i can handle it with the gform\_confirmation\_loaded event. For the redirection case, i had to change the behavior.  
I used the gform\_confirmation filter ([https://docs.gravityforms.com/gform\_confirmation/](https://docs.gravityforms.com/gform_confirmation/)) to change redirections to confirmations message and handle myself the redirection. It’s the case number 3 in the documentation.

But i have a problem with the AJAX return. When the form if configured with text confirmation, the AJAX return is like this :

```auto
<div id='gf_4' ...></div>
<div id='gform_confirmation_wrapper_4' ...> <div id='gform_confirmation_message_4' ...>My confirmation message</div></div>

```

When i change the confirmation from a redirection to a message, the AJAX return is only :

```auto
My confirmation message

```

This is leading to a JS bug because the gf\_4 container does not exists anymore :

```auto
Uncaught TypeError: Cannot read properties of undefined (reading 'top')

```

```auto
jQuery(document).scrollTop(jQuery('#gf_4').offset().top - mt)

```

The problem is in form\_display.php (line 1307). It stops the script and gform\_confirmation\_loaded is never triggered.

Am I missing something or is it a bug ?

I’m sorry if it’s not clear but english is not my language.

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [March 12, 2023, 11:59am UTC](https://community.gravityforms.com/t/problem-with-gform-confirmation/14416/2 "2023-03-12T11:59:52Z")

</div>

Closed on March 12, 2023, 11:59am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
