Я пытаюсь вернуть объект из вызова AJAX.
У меня есть вызов AJAX, который выглядит так:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(this.readyState === 4 && this.status === 200){
//success
var object = JSON.parse(this.responseText);
}
};
xhttp.open("GET", "newjsp.jsp", true);
xhttp.send();
и JSP file:
<%@page contentType="application/json" pageEncoding="UTF-8"%>
<%
JSONObject json = new JSONObject();
json.put("name", "value");
out.print(json);
out.flush();
%>
После теста я получил эту ошибку: Uncaught SyntaxError: Неожиданное число в JSON в позиции 61 в JSON .parse () в XMLHttpRequest.xhttp.onreadystatechange
Кто-нибудь может мне помочь?