简体   繁体   中英

jstl c:set is not working on js code in jsp file

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">'+'%&nbsp;'+intDiscount+'</span>';
                        }

Thanks everyone

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM