ho questo codice:XMLHttpRequest cambia POST per OPZIONE
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));
quando l'invio di esecuzione, ho questo registro:
OPTIONS http://localhost:8111/ [HTTP/1.1 405 Method Not Allowed 74ms]
E in localhost: 8111 ho un serverResource reslet che accetta posta , è un problema della stessa politica di origine? Ho modificato il restlet per inserire l'intestazione allow-origin e lo collaudo con un'altra richiesta http GET (in jQuery) e funziona bene. Ho il problema della risoluzione dell'origine perché utilizzo un browser html5 e il mio server inserisce le intestazioni nella risposta, quindi perché l'invio mi mostra questo errore? perché cambiare POST per OPTION? Grazie!
duplicato possibile ?: Credo che nessuno, ma è vero, il problema è la stesso per entrambe le domande, ma la mia sono si riferisce in quanto la domanda che c'è un problema con il browser, e l'altro, prima punta a jquery. Per esperienza il tempo non conta per i duplicati, le risposte sono diverse, ma è vero che entrambe le domande completano lo a vicenda.
Possibile duplicato di [Perché sto ricevendo una richiesta OPTIONS invece di una richiesta GET?] (Https://stackoverflow.com/questions/1256593/why-am-i-getting-an-options-request-instead-of-a -get-request) – Carvallegro