{"id":7809,"date":"2015-10-08T22:15:00","date_gmt":"2015-10-08T21:15:00","guid":{"rendered":"http:\/\/www.wjst.de\/blog\/?p=7809"},"modified":"2015-10-08T22:21:31","modified_gmt":"2015-10-08T21:21:31","slug":"adding-local-json-data-without-ajax-request","status":"publish","type":"post","link":"https:\/\/www.wjst.de\/blog\/sciencesurf\/2015\/10\/adding-local-json-data-without-ajax-request\/","title":{"rendered":"Adding local json data without ajax request"},"content":{"rendered":"<p>I need to include\u00a0a json\u00a0file from a local directory while ajax\u00a0requests did not work in some\u00a0browsers (due to cross domain security issues).  The final solution turned out to be quite simple, just adding a variable definition before the xml code:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nvar json = \r\n&#x5B;\r\n {\r\n    &quot;id&quot;:&quot;0&quot;,\r\n    ...\r\n  }\r\n];\r\nvar json = JSON.parse(json);\r\n<\/pre>\n<p>and including it as as the first script being loaded<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;script src=&quot;js\/json.js&quot;&gt;&lt;\/script&gt;\r\n<\/pre>\n<p>The json var can then be processed in all other scripts.<\/p>\n\n<p>&nbsp;<\/p>\n<div class=\"bottom-note\">\n  <span class=\"mod1\">CC-BY-NC Science Surf , accessed 27.04.2026<\/span>\n <\/div>","protected":false},"excerpt":{"rendered":"<p>I need to include\u00a0a json\u00a0file from a local directory while ajax\u00a0requests did not work in some\u00a0browsers (due to cross domain security issues). The final solution turned out to be quite simple, just adding a variable definition before the xml code: var json = &#x5B; { &quot;id&quot;:&quot;0&quot;, &#8230; } ]; var json = JSON.parse(json); and including &hellip; <a href=\"https:\/\/www.wjst.de\/blog\/sciencesurf\/2015\/10\/adding-local-json-data-without-ajax-request\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Adding local json data without ajax request<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-7809","post","type-post","status-publish","format-standard","hentry","category-computer-software"],"_links":{"self":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/7809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/comments?post=7809"}],"version-history":[{"count":4,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/7809\/revisions"}],"predecessor-version":[{"id":7813,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/7809\/revisions\/7813"}],"wp:attachment":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/media?parent=7809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/categories?post=7809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/tags?post=7809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}