Click here to Skip to main content
15,917,061 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I just started using jquery lately & developed a small application. However the pagesize was increasing because of a lot of javascript code so I am starting to move the code in separate script files. However,

1) I cannot access other jquery plugins functions when I move my code to separate js file because they are located in other script files. How do I use the other libraries in my separate script file ?

2) Am I doing it the wrong way ? This does not work at all in my separate script file (foo.js). It says stringify is not a function

<script src="../assets/scripts/jquery.json-2.2.min.js" type="text/javascript">
</script>

$(document).ready(function(){
    JSON.stringify('test message');
});
Posted

sounds to me like your external script isn't being referenced correctly. if your example is in the root of your application I'd guess your path isn't going to be:

<script src="../assets/scripts/jquery.json-2.2.min.js" type="text/javascript">
</script>


but more likely this:

XML
<script src="assets/scripts/jquery.json-2.2.min.js" type="text/javascript">
</script>


but I can't be 100% sure without further information.
 
Share this answer
 
hi,
First of all check the file path respect to your browsing directory, use firebug to see reference file actually being loaded or not and finally use this code at top of the js file to add reference
/// <reference path="../assets/scripts/jquery.json-2.2.min.js" />

follow the discussion below
http://www.eggheadcafe.com/community/aspnet/3/10131184/how-to-add-javacript-file-reference-in-another-javascript-file.aspx[^]

hope this will help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900