I'm trying to get the response from a xhr request:
...
xhr.send(formData);
var resposta = JSON.parse(xhr.responseText);
console.log(resposta);
...
Console displays this error:
Uncaught SyntaxError: Unexpected end of JSON input
But I can not see where I'm wrong. When I try:
console.log(xhr);
The console returns all right.
XMLHttpRequest {onreadystatechange: null,
readyState: 1,
timeout: 0,
withCredentials: false,
upload: XMLHttpRequestUpload…}
onabort: null
onerror: null
onload: null
onloadend: null
onloadstart: null
onprogress: null
onreadystatechange: null
ontimeout: null
readyState: 4
response: "true"
responseText: "true"
responseType: ""
responseURL: "******"
responseXML: null
status: 200
statusText: "OK"
timeout: 0
upload: XMLHttpRequestUploadwithCredentials: false__proto__: XMLHttpRequest