当页面在我的控制台中加载时,它会显示此错误
Font from origin 'http://example.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.example.com' is therefore not allowed access.
当我调用 ajax 函数时。它显示此错误
XMLHttpRequest cannot load http://example.com/index.php/home/getCity?city=d. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.example.com' is therefore not allowed access.
家庭 Controller 中有哪些ajax功能。但我在另一个 Controller 中。可能是我认为这是问题。我该如何解决这个问题?
最佳答案
对于 Codeignitor 中的跨源资源,您必须在 <?php
启动后立即在 Controller 中包含此行标签
header('Access-Control-Allow-Origin: *');
关于javascript - HMVC Codeigniter 中没有 'Access-Control-Allow-Origin' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33665963/