A
A
Alexey2016-02-07 20:05:44
WordPress
Alexey, 2016-02-07 20:05:44

Why is on_sent_ok in Contact Form 7 not seeing my function?

Site on Wordpress. There is a contact form made on Contact Form 7. In additional settings on_sent_ok: "myFunction();". myFunction() is a function in the included js I wrote. But in the end, after submitting the form, I get an error: Uncaught ReferenceError: myFunction is not defined
What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2016-02-07
@AmateR

Unfortunately, the connection in the footer does not solve the problem.
I did it differently:
1. placed a hidden button with id = "hide_button"
2. in the form settings: on_send_ok: $( '#hide_button' ).click();
3. $('#hide_button').click(function () { ... }); - here is my code in my js.
But an extra element ... some kind of crutch)

M
Mr Crabbz, 2016-02-07
@Punkie

This means that your script is included before the contact form script 7. Move your script to the footer after wp_footer();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question