Hi, I am stuck at a problem, where I want to query a database then send the res.items to the HTML Component. But I don’t know how to send json to the component?
This is the code I have written:
table_Data() // A backend function that gives me the json data;
.then((data) => {
console.log(data)
$w("#html3").postMessage(data);
})
HTML Code -
<html>
<body>
<div id="output" style="background-color: aliceblue;"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/pivot.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>
let receivedData;
window.onmessage = (event) => {
if (event.data) {
receivedData = event.data;
console.log(receivedData)
$("#output").pivot(
receivedData,
{
rows: ["Frame No"],
cols: ["Engine No"]
}
);
}
}
</script>
</body>
</html>