Thursday, 26 September 2013

read js file using ajax not working

read js file using ajax not working

i have js file contains following :
MyApp.STR = {"Hi":"Hi","By":"By", };
i want to read it on HTML page using ajax.
$(document).ready(function() {
var f = "lib/string-en.js";
loadString(f);
function loadString(fileName) {
try {
console.log('called');
$.getScript("lib/string-en.js", function(data) {
console.log("data is"+data);
// Data returned
});
//We don't use the async callback, because we need
the translation in the next method
// console.log('value is '+MyApp.STR.Hi)
} catch (e) {
console.error('Error while loading : ' + fileName);
}
}

No comments:

Post a Comment