From jQuery integration to Wordpress - Frustrating uncaught errors are making me lose

I recently completed a small application on Codepen and decided to transfer it to my Wordpress website. After updating the necessary elements, such as replacing $ with jQuery and adjusting the JSON file location, I encountered some issues in the console.

The program is functioning properly - it successfully accesses the JSON file and retrieves information from it - until I click on a scale button, at which point it suddenly stops working. Initially, there are no errors shown in the console, but after the second failed click, the following error message appears:

Uncaught Error: Syntax error, unrecognized expression: .
    at Function.ga.error (jquery.js?ver=1.12.4:2)
    at ga.tokenize (jquery.js?ver=1.12.4:2)
    at ga.select (jquery.js?ver=1.12.4:2)
    at Function.ga (jquery.js?ver=1.12.4:2)
    at Function.a.find (jquery-migrate.min.js?ver=1.4.1:2)
    at r.fn.init.find (jquery.js?ver=1.12.4:2)
    at r.fn.init.a.fn.find (jquery-migrate.min.js?ver=1.4.1:2)
    at a.fn.init.r.fn.init (jquery.js?ver=1.12.4:2)
    at a.fn.init (jquery-migrate.min.js?ver=1.4.1:2)
    at r (jquery.js?ver=1.12.4:2)

This issue is causing me frustration, as I have previously dealt with problems related to jQuery on this site, although I managed to resolve them eventually. However, this time seems different.

If someone could kindly take a look and help identify the problem, I would greatly appreciate it as I'm currently struggling to address it.

Here is the original (working) version on Codepen: http://codepen.io/JTBennett/pen/NdLWJy And here is the transferred version on Wordpress:

Below is the updated jQuery code for comparison:

jQuery('.A, .As, .B, .C, .Cs, .D, .Ds, .E, .F, .Fs, .G, .Gs').hide();

jQuery.getJSON("https://www.electricherald.com/json/scalesDirSm.json", function(data) {
    console.log(data);
  jQuery('.main-btn').on("click", function () {
    jQuery('#total-scale-men').empty()
    console.log("emptied total-scale-men");
    jQuery('.gcMen ul li button').css({'border' : '1px #666 solid',
   'color' : '#666'})
    jQuery('.scales-men').hide()
    jQuery('.scales-men').fadeIn()
    jQuery(this).css({'border' : '1px #cc4c4c solid',
   'color' : '#cc4c4c'})
        var scale = jQuery(this).data('scale')
        jQuery.each(data,function(i,data){
            if (scale == data.root) {
                jQuery('#total-scale-men').append('<button class="scale-btn" data-css="'+ data.CSS +'">' + data.scale + '</button>');
            }
        });

        jQuery('.scale-btn').on("click", function () {
    jQuery('.nt').hide()
    jQuery('.scales-men').hide()
    jQuery('.gcMen ul li button').css({'border' : '1px #666 solid','color' : '#666'})

      var css = jQuery(this).data('css')
      jQuery.each(data,function(i,data){
        var notes = ['.'+data.noteClass_1,
                     '.'+data.noteClass_2,
                     '.'+data.noteClass_3,
                     '.'+data.noteClass_4,
                     '.'+data.noteClass_5,
                     '.'+data.noteClass_6,
                     '.'+data.noteClass_7,
                     '.'+data.noteClass_8]
      if (css == data.CSS) {
      jQuery('#test').html(notes)
        jQuery('#inf div:nth-child(1)').text(data.root)
        jQuery('#inf div:nth-child(2)').text(data.scale)
        jQuery('#inf div:nth-child(3)').text(data.structure)

        for(var i = 0; i < notes.length; i++)
        jQuery(notes[i]).fadeIn();
      }
      });
  })

    })
}); 

Your guidance on resolving this issue would be immensely appreciated, as I am currently frustrated with the situation dealing with Wordpress. At this point, I wish I had developed the site myself.

Answer №1

After testing on codepen, I was successful in replicating the error by switching to the same version of jQuery that is being used on your live websitehttps://i.sstatic.net/GmVvd.png

Therefore, it is recommended for you to upgrade to jQuery 3.x on your website

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When it comes to choosing between CSS and Angular Animations for supporting animations on both browsers and NativeScript mobile applications, which approach is more effective?

Are angular animations my only option or can I also utilize css animations with native elements on mobile devices? How are css animations from an angular application translated to native mobile, and is this method less effective than angular animations? I ...

Tips for referencing a function declared within a prototype

I have been attempting to enhance a web page by adding functionality using a jquery library that lacks documentation. The problem I am encountering is primarily due to my lack of understanding of the jquery plugin model and/or the inner workings of javascr ...

Using JavaScript on an iPhone to automatically launch Safari when clicking on a link from a non-default iOS

When "googlechrome://www.lego.com" is opened in mobile Safari, it switches to the Google Chrome iOS app to open the URL. This feature allows for scriptlets like the following one, which enables you to open the current page in the Google Chrome iOS app from ...

The WooCommerce mini cart fails to refresh after items are added using AJAX

I have successfully implemented adding multiple items with quantities to the cart using AJAX. However, after adding a product, the mini cart is not updating as expected. I am calling WC_AJAX::get_refreshed_fragments() in my function.php and have a hook set ...

Utilizing :checked selector and toggle() function in jQuery

I'm facing an issue with my jQuery code where the CSS changes are not working as expected. When I test the code, it doesn't apply the CSS changes. If I remove the :checked and just use $("input"), then the CSS works but only when clicking on an i ...

challenges with positioning div elements using relative CSS styling

This is a section of my code: CSS : .body .left, .right { position:relative; z-index:6; display:inline-block; } .body .left { top:0; left:0; width:100px; height:300px; margin-right:10px; borde ...

Utilizing Angular to incorporate a JSON file within a form

Recently, I've delved into the world of angular and node.js. My current challenge involves populating html forms with content from a json file based on dropdown selection. While I've successfully achieved this, I encounter an issue when manually ...

Attempting to assign a File object as a property to a component but receiving an empty object in return. I'm curious about the security implications of this as well

I created a modal for previewing avatars with a generic design: <avatar-update :img-file="avatarFile" :show="avatarModalShow" :img-url="url" @close="avatarModalShow = !avatarModalShow" :change-avatar="updateCrop" @destroyUrl="imgUrl = null"> </av ...

What could be the reason that setting document.body.style.backgroundImage does not apply to the body element itself?

Consider an HTML document with the given CSS: body { background: url("http://via.placeholder.com/200x200"); width: 200px; height: 200px; } Why does the following code not display the background image URL when executed: console.log(document.body. ...

What is the best way to add dynamic content to an infinite scroll feature within a masonry layout

I've created a mobile web app that uses masonry for displaying images in a pinned format. I now want to incorporate an infinite scrolling feature into my app. I attempted to use jquery.infinitescroll.js for this purpose, but I prefer to load the image ...

``Please note that the Sinon spy.called method is currently not

Context In my setup, a small server receives data from a machine. Each time a message is received, a function in a dispatcher object is called, which simply logs everything it receives to the console. Issue While I can see the logs in the console, Sinon ...

What is the procedure for manipulating a string within an array of objects with a string key-value pair using underscore.js?

I am seeking a solution utilizing underscores, but I am open to a vanilla JS alternative if it proves to be the most effective option. My goal is to utilize array 2 to modify strings in the objects of array1 that either start with or end with the strings ...

Getting specific data from JSON Path extractor with a condition

In need of extracting the value under "currentApproversStr:" when the condition "status":"Ready for Review" is met in the JSON Response body obtained from an HTTP sampler, which will then be passed to another HTTP sampler. Attempted approach that failed: ...

Is there a way to access the result variable outside of the lambda function?

My goal is to retrieve data from an external API using Typescript. Below is the function I have written: export class BarChartcomponent implements OnInit{ public chart: any; data: any = []; constructor(private service:PostService) { } ngOnInit( ...

Begin one lesson, end all others

Looking for help with my expandable list menu that I created using jQuery. Here is the code snippet: $("#menu ul li ul").hide(); $("#menu ul li").click(function() { $(this).find("ul").slideToggle(); }); You can view the fully functional menu on jsFi ...

Stripping Quotation Marks from String and Converting to JSON using PHP and Regular Expressions

While there may be similar questions posted here, I have been unable to find a solution. Therefore, I am writing this to inquire about the possibility of removing quotes from a string before and after curly braces. Is such a transformation feasible? Initi ...

Refreshing Ajax in a different tab causes the selectize element to become unbound from the editing form in Rails 5

In my Rails 5.1 application, I have multiple views with the main view being the calls index view. In this view, I perform an ajax refresh of partials and use a callback to re-initialize the selectize JS element in the calls/index view as shown below: < ...

Modifying iframe elements dynamically across domains

I am faced with the challenge of embedding an iframe form from a web application that I use onto my website. This custom inquiry form is integrated into my diary within the web app, and now I want it to be displayed on my main website while maintaining a c ...

"Troubleshooting: Issues with Ajax's .load() function disrupting

I'm encountering a strange issue where the load() function is causing my carousel to malfunction. Within my Slick Slider, I have 3 slides. You can navigate to the next slide by clicking the NEXT button. Alternatively, clicking on the slide itself loa ...

jQuery form experiencing a small problem

I need assistance with a form that has four fields. Specifically, I am looking for a solution where the visibility of the County field is dependent on the selection made in the Country field. When UK is chosen in the Country field, I want the County field ...