我試圖加載一個本地HTML文件在div中時,按下了下面的jquery加載命令。「MLHttpRequest無法加載文件:///path/to/file.html」錯誤
$("#div_name").load("local_html_file");
但我得到以下錯誤。
MLHttpRequest cannot load file:///path/to/file.html. Received an invalid response. Origin 'null' is therefore not allowed access.
我沒有運行任何特殊的服務器。使用Chrome運行我的html文件。我搜索了它,並知道問題是什麼,但不知道如何解決。
這被認爲是安全違規:前
它進行了討論。 – Pointy 2014-08-28 14:09:33
我該怎麼辦? – 2014-08-28 14:09:55
你可以做的是使用JSONP,或者設置一個本地服務器。 – 2014-08-28 14:10:42