OPCIONES jQuery CORS de tipo de contenido
Tengo problemas con el envío de la solicitud de cuerpo AJAX utilizando jQuery CORS con tipo de contenido personalizado. Aquí está mi código:
$.ajax({
url: "http://some-other-domain/my-path",
type: "POST",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({
key: 1,
key2: 2
}),
statusCode: {
200: function(data) {
}
},
xhrFields: {
withCredentials: true
},
crossDomain: true
});
Necesito configurar el tipo de contenido como "application / json" ya que requiere del servidor. Pero en lugar de enviar una solicitud como POST, jQuery lo envía como OPCIONES.
Aquí hay un encabezado:
Cabeceras de respuesta:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 03:00:00 EET
Set-Cookie: JSESSIONID=BB9D6783E58FB0F2ADE1924A2F0CBA52; Path=/
Content-Type: text/html;charset=UTF-8
Content-Length: 6233
Date: Fri, 07 Sep 2012 14:41:13 GMT
Encabezados de solicitud:
OPTIONS /my-path HTTP/1.1
Host: MY-HOME-NAME
User-Agent: MY_USER_AGEMT
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Origin: HERE-GOES-DOMAIN
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type
Pragma: no-cache
Cache-Control: no-cache
CORS funciona muy bien, todos los encabezados requeridos se envían por servidor, pero no si se envían por tipo de OPCIONES. ¿Es cuestión de jQuery?
jQuery - 1.8.1