0

I have problem when i try to make an ajax request to a controler's function. (Codeigniter)

Each time i make a request i get this error message:

Blocking a multi-origin request (Cross-Origin Request): the "Same Origin"
policy does not refer to the remote resource on http: //localhost/test.php. 
Reason: CORS header "Access-Control-Allow-Origin"

I tried to add this in the top of php script (controler):

header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: POST");   

But this not solved the problem ... when i use it in an external php script (Not codeigniter script) this work well.

Did you have an idea about how to solve this issue ?

Or another approch to send ajax request ?

This question related to codeigniter, not same with pure php code.

Better Fly
  • 23
  • 6
  • approach in [this answer](http://stackoverflow.com/a/9866124/1175966) should do what you need – charlietfl Oct 13 '16 at 19:07
  • I want to solve the problem ?! i get the error message each time a make ajax call ! and in codeigniter not same as pure php ... – Better Fly Oct 13 '16 at 19:21
  • sure it is. Codeigniter is written in php. I have personally used that set up in codeigniter also – charlietfl Oct 13 '16 at 19:25
  • I just used it and don't work ! i learned that there an ouput library but i don't know how to use it and call it for use. this method do not work since i notified it in the post ! – Better Fly Oct 13 '16 at 19:55

0 Answers0