Skip to main content
Sant_Singh_Rath
Adobe Champion
Adobe Champion
October 7, 2019
Question

Form not loading when we added the javascript in richtext...

  • October 7, 2019
  • 1 reply
  • 3523 views

Hi There,

Hope all are doing well. I have experienced unusual behavior with the Marketo form today. We have added the javascript code inside rich-text and that was working completely fine until today.  

When I created a Marketo landing page and placed the form with javascript inside rich-text, form is not loading and when I removed that script, it's working fine.

Is there anyone else who is facing the same issue?

Or should I move the script into our server for the best experience? Please suggest.

Best,

Sant

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
Level 10
October 7, 2019

You'd have to supply a URL. Can't troubleshoot your page without seeing it.

Sant_Singh_Rath
Adobe Champion
Adobe Champion
October 7, 2019

Thanks, Sire! Here is the link for Marketo page where the form is not loading: myfuture.sae.edu/js-testing.html (when we edit the page it's visible)

However, the same form is added on the website page as well and working fine. website page URL: Enquire Now 

~ Sant Singh Rathaur
SanfordWhiteman
Level 10
October 7, 2019

It's a clear race condition, because you're asynchronously injecting a (redundant) jQuery library and then trying to access it immediately. This doesn't happen on the other page because the jQuery library is also loaded earlier.

The best solution is of course to avoid using jQuery at all, since it distracts from learning real JS.

But if you must use jQuery, you still don't need to reload it in the Rich Text. The Forms 2.0 library already includes jQuery. 

So you can remove

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

and use MktoForms2.$ instead of $.

As an aside, this is just terrible code:

If you're testing for the string "interactive", then test for the string "interactive"! Don't understand what would possess someone to look for the letters "in" anywhere in a string instead of the actual match. Such extreme "shortcuts" (which actually are bugs) are unacceptable on a professional site.