0

Here's the scenario. I have written some functions in a js file common.js and included it above another js file let's name it x.js

Now when I try to call those functions (written in common.js) in x.js under the window.onload function - an error pops out in the console saying reference error: not defined.

Now even I tried to use an alert in common.js - it does not pop out ?

mosiac
  • 26
  • 2
  • 3
    maybe you can find here the solution: http://stackoverflow.com/questions/950087/include-javascript-file-inside-javascript-file – markus Jan 27 '13 at 13:00
  • 1
    Please, make a clear question. Show some code. I can just say you forgot to add common.js to your html, but I have no idea if I'm right. – iurisilvio Jan 27 '13 at 13:02
  • Nope i did not forget to add js file, obviously not my friend - It appears to be a known issue. @markus the link you gave worked :). Posting the solution as the answer below – mosiac Jan 27 '13 at 14:12

1 Answers1

0

Found the solution - Thanks @markus for the link.

To this to solve such a problem: Put content of x.js content withing these:

$.getScript("common.js", function(){


   // everything inside x.js here 

});

Now just include x.js (updated) in your html

Community
  • 1
  • 1
mosiac
  • 26
  • 2