![](/img/trans.png)
[英]Is there any way to create an XML file with an html form data with JavaScript?
[英]Any way a javascript in a html file with file:// origin can load a json file data?
我正在構建一個應該從本地磁盤加載的 html 報告。 像c:\report\index.html
。
本地目錄包括以下文件:
c:\report\index.html
c:\report\data.json
我試圖讓 html 文件中的 javascript 加載data.json
上面提到的,使用JSON.parse
。 我使用的每一種技術都會收到錯誤消息,即 CORS 策略禁止從file://
加載 json 文件,即使我試圖從 ZFC35FDC70D5FC69D269883A822C7A5E 文件的同一目錄位置加載它。
我希望我不必放棄這種方法,因為結果將是有益的。 一個簡單的報告。html 無需任何其他程序或工具即可呈現復雜的 json 數據。 只是一個現有的 chrome 瀏覽器。
有沒有可能做這個任務?
您必須首先創建另一個文件夾並將其命名為 example.json 文件。 之后,您可以輕松地加載數據。 不是 json.parse
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.