1

I am getting this error Uncaught ReferenceError: jQuery is not defined with 400 error on the debug programmer console of chrome. The problem when loading is in checkout onepage and the continue button is not working. I supose this is related to a non reference to jquery. How can we link to this .js file and where should i look for it? I believe this is related to the theme i am used but it worked in the past.

enter image description here

After more debugging i am getting the conclusion that the button on the page is missing the html tag for calling the js function that was suposed to be in it. This is the html page: enter image description here

After looking in the magento files there are only 2 files that can generate that code located at: app\design\frontend\base\default\template\checkout\onepage\billing.phtml app\design\frontend\base\default\template\persistent\checkout\onepage\billing.phtml enter image description here The odd thing is i have tested change or remove the files but the page error is still generated. I have cleared the magento cache in admin and in /var/cache

3 Answers3

1

Write your js code like this.

<script type="text/javascript">
    require(['jquery'], function($){
        //Your js code
    })
</script>
Nayem323
  • 751
  • 1
  • 7
  • 26
  • I thing this error in not on the js. I am suspecting of something overriding the expected html. Added details in description. – user3566326 Dec 13 '19 at 01:28
1

If you are using custom js then follow the below code.

var config = {
    paths: {
            'myslider': 'Vendor_Module/js/myslider.min'
    },
    shim: {
            'myslider': {
                deps: ['jquery'] //gives your parent dependencies name here
            }
    }
};

you can get full reference from below link

Rakesh Jesadiya Blog

0

Add below code Above the jQuery('.btn').click(function (){

var $jq = jQuery.noConflict();

And replace "jQuery" with "$jq", SO your code should look like

var $jq = jQuery.noConflict();
$jq('.btn').click(function (){
    //Your code here;
});

If the error still shows, You have to find the default jQuery variable which used for other scripts on your site and replace it within the newly added noConflict line.

Hope it will help you.

Kishor Thummar
  • 3,000
  • 1
  • 9
  • 18
  • I thing this error in not on the js. I am suspecting of something overriding the expected html. Added details in description. – user3566326 Dec 13 '19 at 01:29
  • Confirmed i was missing the file causing the problem. It was due the instalation of a module in the template. Could not use the jQuery. Instead i am using the onclick html tag on the button to call the js function. It was hard but solved. – user3566326 Dec 13 '19 at 03:23