Here is my code:
$( document ).ready(function() {
$.getJSON('onlineinsurance/services/aggregateRating.php', { rating: false } , function(result) {
$("#rating-value").text(result['avg_rating']);
$("#rating-count").text(result['count']);
schema_org = ` <script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": "Some name",
"image": "some image path",
"description": "some description",
"brand": "some brand name",
"offers": {
"@type": "AggregateOffer",
"priceCurrency": "BGN",
"lowPrice": "176.93",
"offerCount": 10
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "'` + result['avg_rating'] + `'",
"reviewCount": "'` + result['count'] + `'"
}
}
</script>
`;
$("#schema-org").after(schema_org);
});
});
And HTML:
<p id="schema-org"></p>
I cannot handle from where problem comes, If I change this row:
$("#schema-org").after(schema_org);
to
$("#schema-org").after('test');
for example, it works perfect, so I think that multiply rows string is the problem? Am I wrong?
EDIT: Okay .. major problem was in me, when I ispect with cntrl + u the string doesn't appear but when I inspect with f12 it is there!