0

I'm developing Google Chrome extension. I have a static countryList.js file which is placed locally in the same folder with another file with the code below. I just want to load countryList.js content into js variable of the second file, but my code doesn't work, though it works if countryList.js is placed on a remote server. What am I doing wrong? I can not place it on the server because it is forbidden for Chrome extensions.

 var countryList = $.get("countryList.js" + localStorage.uid + "&ver=" + localStorage.version, function () {
   callback()
 }
hasan
  • 3,484
  • 1
  • 16
  • 23
Ronny
  • 97
  • 10

2 Answers2

0

Possible duplicate: How can I load a local file using jQuery? (with file://)

GET requires an HTTP connection, so without a local web server it won't work. While you can open and read a file using HTML5, you can't load a JavaScript resource that way.

If the page is loaded locally, you'd usually load the JS using a script tag.

<script type='text/javascript' src='/objectData.js'></script>
Caique Romero
  • 613
  • 8
  • 16
0

Aren't you missing a "?" after countryList.js in your get url?

Bowen Yang
  • 146
  • 1
  • 9