Come testare xmlhttprequest con jasmine
-
29-10-2019 - |
Domanda
Come posso testare l'OnreadyStateChange su XMLHTTPREQUEST o PURO JavaScript Ajax senza jQuery? Lo sto facendo perché sto sviluppando l'estensione di Firefox. Immagino di dover usare le spie, ma non riesco a capire come perché il mio Ajax non restituirà nulla.
submit : function() {
var url = window.arguments[0];
var request = new XMLHttpRequest();
request.open("POST", 'http://'+this.host+'/doSomething', true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send("param="+param+"&emotions="+this.getParams());
request.onreadystatechange = function() {
if(this.readyState == 4) {
// alert(this.responseText);
}
};
}
Nessuna soluzione corretta
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow