0

I'm using magento 1.9 version.

I am creating custom module, which contains some javascript functions to be included.

I defined all javascript functions in seperate js file and included that js in my xml file under app\design\mytheme\default.

Called the js function in my phtml file. It shows the error : (index):403 Uncaught ReferenceError: myFunction is not defined. How to solve this.

  • can you attach XML and JS files here? – Neklo.com Jul 6 '16 at 9:10
  • Sorry i cannot attch my whole XML and JS files due to my company principles. – Saravanan DS Jul 6 '16 at 9:26
0

there can be several reasons of this issue:

1) Js file is not added to page (if something wrong in your XML)

2) Js file not added in Merged js file (so you can clean JS/Css cache at the bottom of Admin - System - Cache Management page)

3) Js file added, but it's code structure broken.

4) Js file added at the bottom of page, but function called before file insertion

  • Thanks for your reply @Neklo. The step 4 is caused my case. Because i called the function On document ready function. But i included the js as normal like <action method="addJs"><script>mymodule/mymodule.js</script></action>. – Saravanan DS Jul 6 '16 at 9:23
  • gimme vote up? ^.^ – Neklo.com Jul 6 '16 at 9:26
  • Is there any way to solve this. – Saravanan DS Jul 6 '16 at 9:28
  • if <action method="addJs"> code added to <reference name="head"> section - you need to clean JS/Css cache at the bottom of Admin - System - Cache Management page – Neklo.com Jul 6 '16 at 9:29
  • and try to call your function like Event.observe(window, 'load', function() { myFunction(); }); – Neklo.com Jul 6 '16 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.