I have an HTML
document with JSON-LD
published as follows:
<script type="application/ld+json">
{
"@context": {
"gs1": "http://vocab.gs1.org/v1#",
"xsd":"http://www.w3.org/2001/XMLSchema#"
},
"@id": "retailer:12345",
"@type": "gs1:Offering",
"gtin13":"5011476100111",
"gs1:hasPrice": {
"gs1:price": "2.49",
"gs1:priceTypeCode": "USD",
"@type":"gs1:Price"
}
}
</script>
This works as expected (meaning it is valid and visible using Google Structured Data Testing Tool
and Structured Data Linter
)
Using Same Origin
(not Cross Origin
), how to move the in-line JSON-LD
to a file?
This approach fails:
<script type="application/ld+json" src="_URL_.json"></script>
This approach also fails:
<script type="application/ld+json">
$(document).ready(function(){
$.ajax({
url: "_URL_.json",
dataType: 'json',
});
});
</script>
How to correct my approach to create a solution where the JSON-LD is in file on my server, not in the HTML?
Next, assume my site is CORS-enabled.
How to publish the JSON-LD structure in a JSONP format so that another domain can subscribe to the JSON-LD data?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…