Error CORS jquery, codeigniter, apache

1

Hi, I have a simple application crud in codeigniter and sql server 2000, in which all queries to the database are made through jquery ajax. I developed it on my local PC windows 8 with xampp, and everything works fine, until I wanted to upload my application to the server, and that was when I got an error and it did not work. The chrome console says:

XMLHttpRequest can not load link . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access.

And firefox: Cross-origin request blocked: The same origin policy does not allow the reading of remote resources in localhost / Retenciones / index.php / Welcome / getMedicos? Term = ami. (Reason: CORS header 'Access-Control-Allow-Origin' not present)

I guess I am infringing some security but I do not know what it is. Try creating a .htaccess file but the server gives another error.

Any ideas to fix this?

thanks

    
asked by daniel 18.10.2016 в 14:00
source

3 answers

1

The problem that you are getting is due to the configuration of your server, on the browser side there is not much that can be done, the problem is that you are making a cross-origin request, that is, from a domain A you want get information from domain B, which is not allowed, for more information you can visit

link

If you have access to the server and its configuration, I recommend visiting

link

where you will find several ways to enable CORS on your server.

    
answered by 18.10.2016 / 15:15
source
0

The errors that you receive, are from your server, are permissions that your server does not have so that from another place you can call or access those functions that locally if you had, I leave an interesting article on this

cross on ajax requests

Also a Stackoverflow Link with your same problem and its solution.

XMLHttpRequest error

    
answered by 18.10.2016 в 14:14
0

Can you enable the CORS on the side of your SQL SERVER? if so, you should do it, although I do not know if it's good to have the sql connected directly to the view

    
answered by 04.01.2018 в 06:11