Array Error in JavaScript

0

Hello, I am putting a zanox script on my site to do product retargeting in an e-commerce.

When I put the script to pull insulated variables everything works, but when I need to pull the variables inside an Array, it does not work.

Here is the script that is right:

<script type="text/javascript">
var zx_identifier = "<%=RSProdutoDetalhe("Codigo")%>",
var zx_fn = "<%=RSProdutoDetalhe("Nome")%>",
var zx_category = "<%=RSProdutoDetalhe("Categoria")%>"
</script>

Here is the script that is wrong:

<script type="text/javascript">
var zx_products = [{
"zx_identifier" : "<%=RSProdutoDetalhe("Codigo")%>",
"zx_amount" : "<%=PrecoProdutoCarrinho%>",
"zx_currency" : "BRL",
"zx_quantity" : "<%=RSPedidoTempGrade("Quantidade")%>"
}];
</script>

Then you would have to loop to get all the possible products on the page within that array

Can anyone help me? Thanks

    
asked by anonymous 24.03.2017 / 19:18

1 answer

0

Use the JSON.stringify, below:

var zx_products = JSON.stringify({
"zx_identifier" : "<%=RSProdutoDetalhe("Codigo")%>",
"zx_amount" : "<%=PrecoProdutoCarrinho%>",
"zx_currency" : "BRL",
"zx_quantity" : "<%=RSPedidoTempGrade("Quantidade")%>"
});

More details: link

    
24.03.2017 / 21:19