16

Is it possible to externalize json-ld and include it in an html document like this:

<script type="text/javascript" src="http://www.example.com/data123.jsonld"></script>

There doesn't seem to be any documentation about this online....

mako
  • 634
  • 1
  • 8
  • 17

1 Answers1

-5

You can't do that. You should get the json with an AJAX request.

You can do it easy with jQuery

JS

$(function(){
  $.getJSON("data123.jsonld", function(data) {
      $('.json').text(data);   
  });
});

HTML

 <div class="json"></div>

If your json file is not in your file system (cross domain) you should try something like this.

Community
  • 1
  • 1
ianaya89
  • 4,153
  • 3
  • 26
  • 34