Answer the question
In order to leave comments, you need to log in
How to display smarty in js?
Hello, can someone tell me how to display the numbers output from the database through smarty in js?
tried like this
{literal}
<script>
$.ajax({
url: 'useraccount.php',
dataType: 'json',
method: 'post',
success: function(data)
{
var all_views = JSON.parse(data);
new Chart(document.getElementById("myChart"),
{"type":"doughnut",
"data":{"labels":["Red","Blue","Yellow"],
"datasets":[{"label":"My First Dataset",
//сюда {$total_views}
"data":[0,0,{$total_views}],
"backgroundColor":["rgb(255, 99, 132)",
"rgb(54, 162, 235)",
"rgb(255, 205, 86)"]}]}});
}
});
</script>
{/literal}
Answer the question
In order to leave comments, you need to log in
it seems to work like this
{literal}
<script>
new Chart(document.getElementById("myChart"),
{"type":"doughnut",
"data":{"labels":["Red","Blue","Yellow"],
"datasets":[{"label":"My First Dataset",
"data":[0,0,{/literal}{$total_views}{literal}],
"backgroundColor":["rgb(255, 99, 132)",
"rgb(54, 162, 235)",
"rgb(255, 205, 86)"]}]}});
</script>
{/literal}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question