tengo este código:XMLHttpRequest cambios de puestos de OPCIÓN
net.requestXHR = function() {
this.xhr = null;
if(window.XMLHttpRequest === undefined) {
window.XMLHttpRequest = function() {
try {
// Use the latest version of the activex object if available
this.xhr = new ActiveXObject("Msxml2.XMLHTTP.6.0");
}
catch(e1) {
try {
// Otherwise fall back on an older version
this.xhr = new ActiveXObject("Mxsml2.XMLHTTP.3.0");
}
catch(e2) {
//Otherwise, throw an error
this.xhr = new Error("Ajax not supported in your browser");
}
}
};
}
else
this.xhr = new XMLHttpRequest();
}
net.requestXHR.prototype.post = function(url, data) {
if(this.xhr != null) {
this.xhr.open("POST", url);
this.xhr.setRequestHeader("Content-Type", "application/json");
this.xhr.send(data);
}
}
var rs = new net.requestSpeech();
console.log(JSON.stringify(interaction));
rs.post("http://localhost:8111", JSON.stringify(interaction));
cuando el envío ejecutar, tengo este registro:
OPTIONS http://localhost:8111/ [HTTP/1.1 405 Method Not Allowed 74ms]
Y en localhost: 8111 tengo un serverResource reslet que aceptamos post , es problema de la misma política de origen? he modificado el restlet para poner el encabezado allow-origin y lo pruebo con otra solicitud GET http (en jquery) y trabajo bien. Tengo el problema de resolver el mismo origen porque uso un navegador html5 y mi servidor pone los encabezados en la respuesta, entonces, ¿por qué el envío me muestra este error? ¿Por qué cambiar POST por OPCIÓN? Gracias!
duplicado Posible ?: Creo que no, pero es verdad, el problema es la mismo para ambas preguntas, pero lo mío es se refiere ya que la pregunta que hay un problema con el navegador, y el otro, primero apunta a jquery. Por experiencia, el tiempo no cuenta como duplicado, las respuestas son diferentes, pero es verdad que ambas preguntas complementan entre sí.
Posible duplicado de [¿Por qué recibo una solicitud de OPCIONES en lugar de una solicitud GET?] (Https://stackoverflow.com/questions/1256593/why-am-i-getting-an-options-request-instead-of-a -get-request) – Carvallegro