Im using an ajax json response to build some html to place in a webpage. Occasionally I'll come across an empty value in my json. This results in an empty object being placed into the html.
I would prefer not to check that each value is not an object, as that doesn't seem efficient. Is there a better way? my code works like this
var firstVar=jsonObj.fristVar; var secVar=jsonObj.secVar; var thirdVar=jsonObj.thirdVar; var fourthVar=jsonObj.fourthVar; ... var htmlResponse='<div class="'+firstVar+'">'+secVar+'<span class="'+thirdVar+'">'+fourthVar+'</span>...'; jQuery("body").html(htmlResponse);