jquery - Check if there's a name present in json -
I want to know that the json file has a 'archive' of the contents if it does and if it does not exist Many JSON files are present, so I will show it with a name and without the name of one.
I do not know what is the best way to check my jQuery function.
JSON
// name store is present // {archive: {image: {}, product: {}, // etc}} < / Image> {name: {}, content: {}, // etc}} // name does not exist // // catalog (or text page): What I try to do is something like this:
function widget (catid, kathraff) {var url = catHref; $ .getJSON (url, function (jsn) {if (collection == true) {console.log ('yes products'); // create some HTML; and {console.log ('no sir no products'); / I have tried things like 'proprieti' or 'typewrite' or 'undefined' etc. but not with any luck. But can not it be difficult? Anyone?
if (json ["archive"]) {...} or
if (json.collection) {...} You obviously undefined and / or null for example, if (json .collection! == undefined) {... } If it can be sent as false . , div>
Comments
Post a Comment