I have a JSON from a service. I am appending a html block by JSON value and I have to check some values for appropriate display. I am trying to set discountValue variable but it not working with js variable. How can I solve it?
if (data!="")
{
$.each(data,function(index,element){
var intDiscount=parseInt(10);
console.log("intDiscount::"+intDiscount);
var strIndex='';
strIndex+='<div class="card">';
strIndex+='<c:set var="discountValue" value="'+intDiscount+'"/>';
console.log("${discountValue}");
...
...
...
...
}
$('#visilabs-FavouriteCategoryTopSeller').append(strIndex);
Console log:
intDiscount::10
0
I have solved it with using if condition with js:
if(element.discount>0){
strIndex+= ' <span class="label label-danger discount">'+'% '+intDiscount+'</span>';
}
Thanks everyone