When Page loads in my console it shows this error
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.
and when i call ajax function. it show this error
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.
Which ajax functions are in home controller. But i'm in another controller. may be I think it was problem. how can i solve this ?
对于Codeignitor中的跨域资源,必须在<?php
标签开始后立即在控制器中包括此行
header('Access-Control-Allow-Origin: *');
<?php
header('Access-Control-Allow-Origin: *');
class Myclass extends CI_Controller {
}
This works perfectly fine in codeigniter
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.