Back to LanguageTool Homepage - Privacy - Imprint

Post method


(Aafreen) #1

Currently, I am using languagetool in “GET” method. is it possible to convert it into “POST” method via java code.
http://localhost:8081/v2/check?language=en-US&text=sample text.


#2

var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open(“POST”, ‘http://localhost:8081/v2/check’);
xmlHttpRequest.setRequestHeader(‘Content-Type’, ‘application/json;charset=UTF-8’);

xmlHttpRequest.onabort = function (e) {
console.log(‘XMLHttpRequest aborted. Do processing here.’);
};

xmlHttpRequest.onerror = function (e) {
console.log(‘An error occurred. Do processing here.’);
};

xmlHttpRequest.onreadystatechange = function () {
if (xmlHttpRequest.readyState == XMLHttpRequest.DONE && xmlHttpRequest.status == 200) {
console.log(‘XMLHttpRequest finished. Do processing here.’);
}
};

xmlHttpRequest.ontimeout = function (e) {
console.log(‘XMLHttpRequest timed out. Do something here.’);
};

var spellCheckerParameters = ‘language=’ + encodeURIComponent(‘en-US’)
+ ‘&text=’ + encodeURIComponent(‘sample text’)
+ ‘&disabledRules=WHITESPACE_RULE’

xmlHttpRequest.send(spellCheckerParameters);