Skip Navigation

[Resolved] Javascript error in console causing AJAX results to not work.

This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 7 replies, has 2 voices.

Last updated by Ben 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1191509

Ben

I believe that I have spotted a Javascript error in the console that is stopping AJAX results updating from working, or at least affecting them.

I can see these two errors:

Uncaught TypeError: $.ajax is not a function

and

Uncaught TypeError: n.find(...).fadeOut is not a function

How do I go about finding out what is causing this?

#1191683

Hi, sometimes this is an indication that a theme or another plugin is enqueueing the jQuery library in a way that is not compatible with best practices. Can you try the following troubleshooting steps first?
- Temporarily deactivate all plugins except Types and Views, then activate a default theme like Twenty Seventeen.
- Test again. If the problem is resolved, reactivate your parent theme, then child theme, then other plugins one by one until the problem returns.
- If the problem was not resolved, check your site content to see if the jQuery library was added somewhere like a custom code snippet area. If so, that should be removed.

Let me know what you find out and we can go from there.

#1192083

Ben

Thanks for your reply Christian.

I have followed these instructions, all plugins are fine but it seems to be the Child Theme that I am using that is causing the problem. There is no issue when I use the Parent Theme though, just the Child.

If this is something you can help me with then what are the next steps?

#1192113

Ben

Another thought, is the jQuery library enqueued with Bootstrap 3 by default?

As I have deactivated that and I am enqueuing Bootstrap 4 directly currently. Maybe this could have something to do with it?

#1192186

According to their documentation, jQuery is required for some of their JavaScript components but it's not included with the Bootstrap library and should be included separately: https://getbootstrap.com/docs/4.2/getting-started/introduction/
So depending on how your child theme is set up, it may have some code that includes a jQuery script tag directly in some template file, or perhaps it enqueues the script somehow in your functions.php file.

Troubleshooting child themes is outside the scope of support we provide here in the forums, per our support policy:
https://toolset.com/toolset-support-policy/

#1192190

Ben

I will have a look at the Child Theme myself then. Thank you for the help you have already provided Christian.

One question though if that's ok. If I do not enqueue jQuery myself manually, and I set Toolset to not load Bootstrap, how does Toolset enqueue jQuery by itself to use AJAX?

#1192251

jQuery is actually included with modern WordPress installations as a default: https://developer.wordpress.org/reference/functions/wp_enqueue_script/#defaults
It can be used as a dependency in wp_enqueue_script().

#1200080

Ben

Thank you for all your help with this Christian.

Turns out I was enqueuing the slim build of jQuery which excludes AJAX. Started enqueuing the full build instead and all has been resolved.