[jQuery]JSon with Progressbar
JSon:
Code:
{"EXP":"50","Drop":"1","Meso":"15","Accounts":"2","Characters":"101","Logged":"1"}
Script:
Code:
<script type="text/javascript">
$(document).ready(function() {
var items = [];
$.getJSON('./Style/Test.json.php', JData);
function JData(Data) {
$.each(Data, function(key, val) {
if(key == 'Logged')return false;
items.push('<div>'+key+'</div>');
items.push('<div>'+val+'</div>');
});
$('<div/>').addClass('LogProg').progressbar({ value: Data.Logged }).appendTo($('.Sidebar_Content').removeClass('Loader').html(items.join('')));
}
});
</script>
<div class="Sidebar_Content Loader"></div>
my question is how come when i use numbers for the value in the progressbar it works but when i switch it with 'Data.Logged' it fails even though it outputs a number?
Re: [jQuery]JSon with Progressbar
its not a number its a string, try either {"exp": 50}, or parseInt().. also I have no idea what are you trying to do, show me on jsfiddle
Re: [jQuery]JSon with Progressbar
thx fox i didnt realize it was a string output.
i just added the parsInt() and it worked fine.
Code:
function JData(Data) {
var Logged = parseInt(Data.Logged);
$.each(Data, function(key, val) {
if(key == 'Logged')return false;
items.push('<div>'+key+'</div>');
items.push('<div class="lBorder"></div>');
items.push('<div>'+val+'</div>');
});
$('<div/>').addClass('LogProg').progressbar({ value: Logged }).appendTo($('.Sidebar_Content').removeClass('Loader').html(items.join('')));
}