[英]How to fix “Access Control Allow Origin” error when using AJAX to load XML from URL?
我有以下代碼,該代碼使用AJAX從URL加載XML,但是單獨使用該代碼會導致此錯誤: "XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access."
...想法,好嗎?
嘗試以下
將ajax更改為$.ajax({ url: "/php/phpscript.php",
將PHP更改為echo file_get_contents("http://thegamesdb.net/api/GetGamesList.php?name=".$_GET["term"]);
您可能希望對$_GET["term"]
進行清理
如果
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.