JavaScript in Contact Form 7

2019-09-15 16:11发布

问题:

I need a help with Contact Form 7 and additional settings.

I would like to add this script:

<script type="text/javascript" src="https://example.js?mid=0000&refer=example_name"></script>

to

on_sent_ok:

I tried to do it in many ways but it is not working.

回答1:

on_sent_ok expects a string of executable JS code.

So to load and execute an external script, you can use jQuery's getScript, like so:

on_sent_ok: '$.getScript("https://example.js?mid=0000&refer=example_name‌​")'