Javascript 我应该使用PHP实现Schema.org聚合评级吗?
无法处理Schema.org聚合评级的实现 我的代码:Javascript 我应该使用PHP实现Schema.org聚合评级吗?,javascript,php,html,schema.org,Javascript,Php,Html,Schema.org,无法处理Schema.org聚合评级的实现 我的代码: <div id="page-rating"> <form id="rating-form"> <input type="hidden" name="_token" value="myToken"> <input type="hidden" name="page" value="11"> <input type="hidden" na
<div id="page-rating">
<form id="rating-form">
<input type="hidden" name="_token" value="myToken">
<input type="hidden" name="page" value="11">
<input type="hidden" name="a" value="review">
<span class="rating-star">
<input type="radio" name="rating" value="5">
<span class="star"></span>
<input type="radio" name="rating" value="4">
<span class="star"></span>
<input type="radio" name="rating" value="3">
<span class="star"></span>
<input type="radio" name="rating" value="2">
<span class="star"></span>
<input type="radio" name="rating" value="1">
<span class="star"></span>
</span>
</form>
<div id="rating-text">Rating: <span id="rating-value">5.00</span> from 5. Count of votes: <span id="rating-count">9</span> users</div>
</div>
评级:从5.00到5.00。计票:9名用户
脚本:
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": "Some Product",
"image": "path/to/image.png",
"description": "Some Description",
"brand": "Some Brand name",
"offers": {
"@type": "AggregateOffer",
"priceCurrency": "BGN",
"lowPrice": "150.00",
"offerCount": 9
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "5.00",
"reviewCount": "8"
}
}
</script>
{
“@context”:”http://schema.org/",
“@type”:“产品”,
“名称”:“某些产品”,
“image”:“path/to/image.png”,
“描述”:“一些描述”,
“品牌”:“某个品牌名称”,
“提议”:{
“@type”:“AggregateOffer”,
“价格货币”:“BGN”,
“低价”:“150.00”,
“报价金额”:9
},
“聚合”:{
“@type”:“聚合”,
“额定值”:“5.00”,
“reviewCount”:“8”
}
}
好了,现在我不知道更新时该怎么办?如果有人点击
我认为必须发生的事情是,在click to.php文件上发送AJAX,并将新记录添加到某个DB表(mysql)中。然后在页面加载时,通过ajax再次调用.php文件,获得rating+票数,并更新json和div中的值。我说得对吗?一般来说,是的。点击后,您应该发布评级,保存投票,并在回复中发回更改的信息,并更新客户端上的视图。不一定是Ajax,但Schema.org microdata的主要目的是为机器人/搜索引擎提供附加信息。因此,在更新之后直接通过AJAX为当前查看器(可能不是一个机器人)更新数据在大多数情况下可能是不必要的/毫无意义的。下次请求该页面时,您的服务器只需输出更新的数据即可。“您的服务器只需输出更新的”Ok“,但当用户单击stars review时又如何?