Right I am creating a method which adds an Account to Dynamics CRM with an Ajax POST to a built in webservice, the code is as follows :
var context = GetGlobalC
Use a JS Package/Dependency manager like Jingo.js
Make sure all other depending JavaScipt libraries are loaded before this javascipt and you have to maintain the depending javascript precedence. Since you are using Json and JQuery libraries you have to load those libaries first. Also if you are using any function of some other library it has to be loaded (it should be in the top of the list) before this javascript.
Just upload those libraries as additional Web Resources. On the customizations for the form, you can choose which libraries get loaded on the form. Just make sure your JSON and jQuery libraries are loaded before your custom code, and you should be fine.