# JS Callbacks not... callingback

**URL:** <https://community.hubspot.com/t/js-callbacks-not-callingback/11692>\
**Category:** APIs & Integrations\
**Created:** [March 21, 2017, 7:42pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692 "2017-03-21T19:42:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [March 21, 2017, 7:42pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/1 "2017-03-21T19:42:15Z")

</div>

Per the docs there should be callbacks on form submit  
 [developers.hubspot.com](https://developers.hubspot.com/docs/methods/forms/advanced_form_options)

### [How to customize the form embed code](https://developers.hubspot.com/docs/methods/forms/advanced_form_options)

This is a list of options that you can use if you just need to tweak a default hubspot form. If you need complete control over the styles and actions of your form, you will still want to use the Forms API.

I have made a button that pops the form up in a bootstrap window, but the “onFormSubmit” doesn’t ever get called?

Sample:  
[https://cadence-inc.com/playground/hubspot](https://cadence-inc.com/playground/hubspot)  
Open hubspotpopup.js

Any idea?  
Thanks,  
Steve

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [March 22, 2017, 8:00pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/2 "2017-03-22T20:00:09Z")

</div>

[@sitefinitysteve](https://community.hubspot.com/u/sitefinitysteve) Is this still an issue?  
We had a momentary issue with our forms.

> **[Form submission processing is currently delayed for some customers](https://status.hubspot.com/incidents/j1b2htxlvtlz)**
>
> HubSpot's Status Page - Form submission processing is currently delayed for some customers.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [March 22, 2017, 8:13pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/3 "2017-03-22T20:13:16Z")

</div>

Yeah, give it a try, the “onFormSubmit” event just never trips  
 ![sweat.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/a/a3e081930c575dc868d14ad73a024af2a48a1564.png)

Does something need to happen on the server to allow a post return from your domain or something? …I can see it all working in the console, and I can see the form DATA in hubspot… but the js event never returns.

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [March 23, 2017, 3:25pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/4 "2017-03-23T15:25:40Z")

</div>

The on form submit should fire after the button is clicked to submit and not after a response from our server. If you simply put a console.log(“in the callback”) in the function does it fire? Do you get any errors?

ex.

```auto
onFormSubmit: function($form) {
 console.log("call back fired")
 }

```

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [March 23, 2017, 3:41pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/5 "2017-03-23T15:41:38Z")

</div>

This is my issue, you can inspect the script on the page to see it not happen. No debug or console gets triggered there. There is actually a debugger; statement in there right now  
 ![confused.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/b/d/bdf4939b5153fcb6b8f7c390c101605ffbc64cce.png)

No errors that I can see  
 ![confused.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/b/d/bdf4939b5153fcb6b8f7c390c101605ffbc64cce.png)

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [March 23, 2017, 5:03pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/6 "2017-03-23T17:03:37Z")

</div>

[@sitefinitysteve](https://community.hubspot.com/u/sitefinitysteve) Is this the form you are referring too?

[

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/0/602ab490a5a2f73e54a8b14892159f5dfc96769b.png)

image.png1218x892 77.5 KB

]([https://community.hubspot.com/legacyfs/online/uploads/default/original/2X/1/151f6e4218958910efd98313489bf77419234022.png](https://community.hubspot.com/legacyfs/online/uploads/default/original/2X/1/151f6e4218958910efd98313489bf77419234022.png))

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [March 23, 2017, 5:15pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/7 "2017-03-23T17:15:00Z")

</div>

Yeah, open your dev tools and inspect “hubspotpopup.js” you can see the callback specified, one of the events triggers, I think it’s formReady(?) but submit does not

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [March 23, 2017, 5:35pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/8 "2017-03-23T17:35:32Z")

</div>

[@sitefinitysteve](https://community.hubspot.com/u/sitefinitysteve) When I ran the create block in the code I can see your first callback firing.

[

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/e/de06a55d26d85f021e2dd0392c8e7ba5b43bdfff.png)

image.png976x272 30.3 KB

]([https://community.hubspot.com/legacyfs/online/uploads/default/original/2X/c/c95727ec6e0548436262d89768ea47beb478cef4.png](https://community.hubspot.com/legacyfs/online/uploads/default/original/2X/c/c95727ec6e0548436262d89768ea47beb478cef4.png))

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [March 23, 2017, 5:47pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/9 "2017-03-23T17:47:09Z")

</div>

Right I know, thats what I keep saying  
 ![slightly_smiling_face.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/2/42c4d129a1c6aa74d89f3066ee8fbb15db46b3b5.png)  
The one fires, but submit does not… submit is the only one I care about the other was just trying to test if I was going insane or not.

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [March 24, 2017, 12:36am UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/10 "2017-03-24T00:36:12Z")

</div>

[@sitefinitysteve](https://community.hubspot.com/u/sitefinitysteve) I’m stumped at the moment on this as well. I fully understand your problem as I can reproduce it now on your site. Let me run this by a couple of my co-workers tomorrow and hopefully we can figure this out.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [March 27, 2017, 4:08pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/11 "2017-03-27T16:08:53Z")

</div>

Been a few days, any clue yet?

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [March 28, 2017, 1:58pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/12 "2017-03-28T13:58:41Z")

</div>

[@sitefinitysteve](https://community.hubspot.com/u/sitefinitysteve) No I don’t I pulled my manager in @zwolfson to lend a hand and we are having trouble pinpointing why this callback doesn’t run on your site. Something seems to be closing the form down after the network request but before the callback can fire. Are you preventing certain events firing some where on your page as a global thing?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [March 28, 2017, 2:16pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/13 "2017-03-28T14:16:09Z")

</div>

Absolutely nothing, pretty bare site, just loading jQuery and Bootstrap really. Like I mentioned above though, it’s a cross domain postback, could that be why? Browser restricting callback for security or anything maybe, server somehow need to allowlist (grabbing at straws)

---

<div class="post-metadata">

**Author:** ![tjoyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tjoyce/32/88832_2.png) [@tjoyce](https://community.hubspot.com/u/tjoyce)\
**Post date:** [March 28, 2017, 2:36pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/14 "2017-03-28T14:36:56Z")

</div>

I am having a similar issue across multiple wordpress sites that have a hubspot embedded form. The form settings are using “inline message” in the form builder but when you submit the form, the page refreshes back to itself. The fact that the console clears after submit, should help debug this issue since it’s supposed to be an inline message, not a redirect.

I have tested on 2 different websites using embedded HS forms

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [March 30, 2017, 3:16pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/15 "2017-03-30T15:16:50Z")

</div>

Hey guys, my client is a customer of hubspot and is kinda of relying on us to deliver this functionality… can we work to a resolution please? I realize this is the only avenue for api support, but I really would like to get this resolved asap  
 ![confused.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/b/d/bdf4939b5153fcb6b8f7c390c101605ffbc64cce.png)

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [March 30, 2017, 4:19pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/16 "2017-03-30T16:19:14Z")

</div>

[@sitefinitysteve](https://community.hubspot.com/u/sitefinitysteve)

You are using the old version of the form code, which I don’t think supported onFormSubmit. If you look at the source or the network tab, you are loading [js.hsforms.net/forms/current.js](http://js.hsforms.net/forms/current.js), and that current.js is actually the older embed code. The actual current code you should use [js.hsforms.net/forms/v2.js](http://js.hsforms.net/forms/v2.js). The original current.js embed code didn’t have the onFormSubmit functionality (it did have onFormReady).

You’ll need to update to use the v2.js file.

You might also need to update the target you are using as well, seems like the old function can deal with using the actual jQuery object:  
target: $(“#” + id + " .popup .modal-body"),

but the new one may only accept the selector as a string:  
target: “#” + id + " .popup .modal-body",

I was able to reproduce the issue on my end using the old current.js file.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [March 30, 2017, 4:32pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/17 "2017-03-30T16:32:32Z")

</div>

That is fantastic sir! …current != current  
 ![smile.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/9/8/983d27b831ee3afc0b7aacc1d2004907b5883eb4.png)

I will mark as complete for now, thx!

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [March 30, 2017, 4:40pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/18 "2017-03-30T16:40:48Z")

</div>

Glad it is working. the current != current through me as well at first.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [June 21, 2017, 8:14pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/19 "2017-06-21T20:14:18Z")

</div>

I’m using the new version of the forms but my callback isn’t firing. My submissions are going through.

I’m using this in the head.

```auto
<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script char-set="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>

```

I have multiple forms instantiated in the page in the form of this:

```auto
window.hbspt.forms.create({
 target: `.${dynamicClassName}`,
 css: '',
 portalId: 'my-portal-id',
 formInstanceId: `form-${dynamicInstanceId}`,
 formId,
 cssClass: dynamicClassName,
 submitButtonClass: 'button button-fill button-form',
 inlineMessage: 'Thanks! We will get in touch with you.',
 onFormSubmit() {
 // This is not triggering!
 console.log("HELLO??");
 },
 });

```

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [June 21, 2017, 8:16pm UTC](https://community.hubspot.com/t/js-callbacks-not-callingback/11692/20 "2017-06-21T20:16:54Z")

</div>

I found out my problem:

```auto
The onFormSubmit function in hbspt.forms.create requires jQuery. It was not run.

```

But seriously, why do you need jQuery??

[Next page](https://community.hubspot.com/t/js-callbacks-not-callingback/11692.md?page=2)
