Codeigniter REST API does not answer

0

Good afternoon! I am making an application that uses an api rest system with Codeigniter REST API. I created the user registration function, and doing tests with postman, all perfect, you can register well and it does not give problems. This api is in link .

Then I have a web app, with a registration form, that by AJAX calls api.mydomain / registration / register and sends the post parameters of the form.

This web app is in web.midominio

The code I use to make the call to the api is this:

<script>
    $("#btn_enviar").click(function(){
        $.post("http://api.midominio.com/registration/register",
            $("#form_registro").serialize(),
            function(data,status)
            {
                alert(data);
            }
        );
    });

</script>

When I click on the button, it calls me to the api and it gives a 200 OK but it does not return any response. For example, if the fields are empty you should receive a JSON with error: true and feedback: "Fill in all the fields". But looking at the chrome inspector does not show me anything.

    
asked by Juan Luis 20.08.2017 в 14:36
source

1 answer

0

Solution:

Add a header in the php code that returns the response, that of permission to an external source, in this case my web app:

 header("Access-Control-Allow-Origin: http://midominio.com");
    
answered by 01.09.2017 / 16:06
source