admin管理员组

文章数量:1402291

I've added jquery 1.8.2 to both my page.xml file and the corresponding directory.. however i am still getting multiple Uncaught ReferenceError: jQuery is not defined errors. I have checked to make sure jquery is loaded as well as noconflict.js. I have also disabled the two jquery versions to see if that would make a difference.

SUBJECT SITE

The magento version i am using is ver 1.8.1.0

Jquery no conflict has been added. (no conflict.js gets undefinded error too)

After adding no conflict js i wrote js like this

$j(document).ready(function(){
// write your code here
});

In the page.xml file the script src is

jquery-1.8.2.min.js and it is the first script.

<block type="page/html_head" name="head" as="head">

    <action method="addJs"><script>jquery-1.8.2.min.js</script></action>

    <action method="addJs"><script>no-conflict.js</script></action>

    <action method="addJs"><script>prototype/prototype.js</script></action>

    <action method="addJs"><script>lib/ccard.js</script></action>

    <action method="addJs"><script>prototype/validation.js</script></action>

ect.

the errors look like this ($j error if after i added $j document function to file) :

Uncaught ReferenceError: $j is not defined guytgunter/shop/~/jquery-1.8.2.min.js:2
Uncaught ReferenceError: jQuery is not defined guytgunter/shop/~/no-conflict.js:1
Uncaught ReferenceError: jQuery is not defined guytgunter/shop/~/ddaccordion.js:249
Uncaught ReferenceError: jQuery is not defined guytgunter/shop/~/ddaccordion.js:151
Uncaught ReferenceError: jQuery is not defined guytgunter/shop/~/jquery.colorbox-min.js:7
Uncaught ReferenceError: jQuery is not defined guytgunter/shop/:221
Uncaught ReferenceError: jQuery is not defined guytgunter/shop/:283
Uncaught ReferenceError: jQuery is not defined guytgunter/shop/:644
Uncaught ReferenceError: jQuery is not defined wecreater/web/~/responsiveslides.min.js:170
Uncaught ReferenceError: jQuery is not defined wecreater/magento/~/noConflict.js:1
Uncaught ReferenceError: jQuery is not defined 

I've added jquery 1.8.2 to both my page.xml file and the corresponding directory.. however i am still getting multiple Uncaught ReferenceError: jQuery is not defined errors. I have checked to make sure jquery is loaded as well as noconflict.js. I have also disabled the two jquery versions to see if that would make a difference.

SUBJECT SITE

The magento version i am using is ver 1.8.1.0

Jquery no conflict has been added. (no conflict.js gets undefinded error too)

After adding no conflict js i wrote js like this

$j(document).ready(function(){
// write your code here
});

In the page.xml file the script src is

jquery-1.8.2.min.js and it is the first script.

<block type="page/html_head" name="head" as="head">

    <action method="addJs"><script>jquery-1.8.2.min.js</script></action>

    <action method="addJs"><script>no-conflict.js</script></action>

    <action method="addJs"><script>prototype/prototype.js</script></action>

    <action method="addJs"><script>lib/ccard.js</script></action>

    <action method="addJs"><script>prototype/validation.js</script></action>

ect.

the errors look like this ($j error if after i added $j document function to file) :

Uncaught ReferenceError: $j is not defined guytgunter./shop/~/jquery-1.8.2.min.js:2
Uncaught ReferenceError: jQuery is not defined guytgunter./shop/~/no-conflict.js:1
Uncaught ReferenceError: jQuery is not defined guytgunter./shop/~/ddaccordion.js:249
Uncaught ReferenceError: jQuery is not defined guytgunter./shop/~/ddaccordion.js:151
Uncaught ReferenceError: jQuery is not defined guytgunter./shop/~/jquery.colorbox-min.js:7
Uncaught ReferenceError: jQuery is not defined guytgunter./shop/:221
Uncaught ReferenceError: jQuery is not defined guytgunter./shop/:283
Uncaught ReferenceError: jQuery is not defined guytgunter./shop/:644
Uncaught ReferenceError: jQuery is not defined wecreater./web/~/responsiveslides.min.js:170
Uncaught ReferenceError: jQuery is not defined wecreater./magento/~/noConflict.js:1
Uncaught ReferenceError: jQuery is not defined 
Share Improve this question asked Jun 19, 2014 at 13:27 user3756611user3756611 131 gold badge1 silver badge3 bronze badges 8
  • You're including jQuery twice. The first time, it's your modified version that uses $j, but it's imported before your "noconflict" file. None of those other scripts are written to expect "$j" to work as a reference to jQuery. – Pointy Commented Jun 19, 2014 at 13:33
  • The first call to jquery 1.8.2, it starts with $j(document) this will not work since your noConflict have not been loaded. The second call to jquery has the correct starting – Huangism Commented Jun 19, 2014 at 13:33
  • @pointy i fixed that problem however i get this error Uncaught TypeError: undefined is not a function when adding $j(document).ready(function(){ // write your code here }); – user3756611 Commented Jun 19, 2014 at 14:02
  • @Huangism i have corrected that however i am still getting many errors even when encasing files in $j(document) function – user3756611 Commented Jun 19, 2014 at 14:03
  • 1 @user3756611 check your work please, you are still calling jquery after the no conflict – Huangism Commented Jun 19, 2014 at 14:25
 |  Show 3 more ments

3 Answers 3

Reset to default 2

1.Check for the order for js inclucded

2.Check for the jQuery URL loaded properly

3.Check for any other version of jquery used in the website and disable it

This will do the job !!!!

One simple mistake I've made in the past is to try using jQuery in the Magento head.phtml file. At this time in the processing cycle the page.xml file won't have been processed and JQuery / noconflict will not be defined even though you'll of course see it when you view source on your page.

If you are using $j, then before writing your script add following line within Script tag -

$j = jQuery.noConflict();

Then proceed with $j.

Also make sure you are using Single jQuery library.

You can check this using Browser Short key Ctrl+U to see the view-source. With the help of this you can check whether library including once or twice.

本文标签: javascriptUndefined jQuery after adding no conflict jsStack Overflow