Here is the way to read Resource.resx files in javascript functions
<script type ="text/javascript">
var currentUICluture = null;
$(document).ready(function () {
SP.SOD.executeOrDelayUntilScriptLoaded(LoadResourceJS, 'core.js');
}); //end of document.ready
SharePoint gives us the ScriptResx.ashx handler which loads the resource file in the js format on the Page.It provides the Res variable which contains all the resources keys in hashTable format.
function LoadResourceJS() {
currentUICluture = STSHtmlEncode(Strings.STS.L_CurrentUICulture_Name);
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', getResourceVal);
}// end of ResourceJS
function getResourceVal() {
var url = '/_layouts/15/ScriptResx.ashx?culture=' + currentUICluture + '&name=resourceFileName';
$.getScript(url, function () {
alert(Res[key]); //for specific key
alert(Res.Key);
});
}//end of getResourceVal
</script
NOTE: key the first alphabet of the key should be in lowercase.