javascript - Load JSON file, error undefined -


i'm trying load json file i'll use constants file, i'm getting error undefined, 1 help?

here code:

function loadjsonfile(filepath){  $.getjson(filepath, function(mydata) {     alert(mydata.length);     return mydata;     }) error(function() { alert("error");  }); 

the structure of constants file is:

{     "var1":"v1",     "var2":"v2" } 

thank in advance help.

function loadjsonfile(filepath, callback){        $.getjson(filepath)         .success(function(mydata) {               callback(data);        })        .fail(function() { alert("error")}); ; });  function dostuff(data){   alert(data.var1) }  loadjsonfile('url', dostuff); 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -