javascript - Applying json data to format style via jQuery -
i have odd problem following:
function loadtextbox(jsonurl,divid){ $.getjson(jsonurl, function(json) { $('#' + divid).html('<h2>'+json.heading+'</h2>'); alert(json.config.headingconfig); $('#' + divid).children().css(json.config.headingconfig); }) }
the alert above returns: {color: 'white', fontfamily:'arial, times, serif'} however, format of text not change.
now here odd part: if this:
function loadtextbox(jsonurl,divid){ $.getjson(jsonurl, function(json) { $('#' + divid).html('<h2>'+json.heading+'</h2>'); alert(json.config.headingconfig); $('#' + divid).children().css({color: 'white', fontfamily:'arial, times, serif'}); }) }
it works fine... text format arial font , white. baffled... means there simple answer, ideas?
it looks json.config.headingconfig
contains json string.
you need convert actual object calling $.parsejson
.
Comments
Post a Comment