I'm getting data as JSON response and each time one of my fields is empty and one has value so I need to make if statement to check which one has value and print that one.
So far I tried:
if(data.longtext_dec != ''){
  var ress = data.longtext_dec;
} else {
  var ress = data.text_dec;
}
and
if($.trim(data.longtext_dec) === '')
{
  var ress = data.longtext_dec;
} else {
  var ress = data.text_dec;
}
each time the code keeps printing longtext_dec or show both as null.
So I need help to get this right, the result of this ress I want to append it in my view (either this or that).
How can I fix this code?
UPDATE
network response tab:
product_id        15
specification_id  5
text_dec          ddd
longtext_dec      null
id                69
payload
{"product_id":"15","specification_id":"5","text_dec":"ddd","longtext_dec":null,"id":69}
 
     
     
     
     
    