Why is my function with headers in ajax not executed?

0

I have problems connecting to a webservice, I have managed to connect with php but I do not need to do it with ajax but I can not move forward, I have realized that the token is never sent, only the OPTIONS request is executed but not the POST, something I am doing wrong ?, I need help.

The problem starts when I add the bearer to the headers, this is my code

function autologin(respuesta){
                            $.ajax({
                                type: "POST",
                                dataType: "json",
                                data: {data:respuesta.data},
                                headers: {"Authorization":  "Bearer "+respuesta.token},
                                url: "webservices.com",
                            }).done(function (data) {
                                console.log(data);
                            });
                        }

This comes to me in the web inspector:

Cabeceras de la respuesta (397 B)
Content-Type    
text/html
Server  
Microsoft-IIS/8.5
X-Powered-By    
ASP.NET
X-Frame-Options 
SAMEORIGIN
Access-Control-Allow-Origin 
*
Access-Control-Allow-Headers    
authorization,content-type
Date    
Fri, 20 Oct 2017 21:37:46 GMT
Connection  
close
Content-Length  
1245



Cabeceras de la petición (474 B)
Host    
host.com
User-Agent  
Mozilla/5.0 (Macintosh; Intel …) Gecko/20100101 Firefox/56.0
Accept  
text/html,application/xhtml+xm…plication/xml;q=0.9,*/*;q=0.8
Accept-Language 
es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding 
gzip, deflate, br
Access-Control-Request-Method   
POST
Access-Control-Request-Headers  
authorization
Origin  
https://midominio.com
Connection  
keep-alive
    
asked by Jesus Cuevas Sanchez 20.10.2017 в 23:50
source

0 answers