i am translating a web pages using this javascript i generated below, i have a problem converting text in an input so i try to put if condition inside my code, if it is an input use return if not use .html, but im having problem with the return because it is not working and i dont know why (please see the comments in the code to give you more info)
function changeLanguage(lang){
$.post("/misc/sessionUpdate.asp",{ 'lang': lang});
$.getJSON("/language/"+lang+".json", function( data ) {
$.each(data, function(property, val){
$('[data-localize]').val(function() {
type = $(this).attr("type");
attrVal = $(this).attr("data-localize");
// if put return data[property]; here it is working but the problem it should be inside the if(attrVal == property)
if(attrVal == property){
if (type == "submit"){
// i already tried console.log (attrVal +"=="+ property) to verify if there is an instance of true and there is
return data[property];
}else{
attrName = '[data-localize="'+property+'"]'; //sample format [data-localize=menu]
$(attrName).html(val); // data[property] is the corresponding value of the key in json
}
}
});
});
}).done(function(){
$('.languageLoader').css('display','none');
});
}
i also put the algorithm in .done function to avoid assynchronus problem in ajax and still not working
thanks in advance guys....