1. 程式人生 > >ajax本地跨域問題

ajax本地跨域問題

round proto supported request png dir .exe fail html

報錯內容 : 04-response.html:48 Failed to load file:///C:/Soft/directory/AppServ/www/04.php: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

原因分析 : 通過file協議瀏覽http時,發送的ajax請求的是本地文件不是http協議,故會報跨域錯誤

解決辦法:

拿chrome瀏覽器舉例,其他瀏覽器也是一樣做法,桌面找到瀏覽器的快捷鍵,點擊右鍵,選擇屬性,在目標內容尾巴上加空格

並添加內容--allow-file-access-from-files

目標(T):C:\Google\Chrome\Application\chrome.exe --allow-file-access-from-files

技術分享圖片

ajax本地跨域問題