В моем веб-сервисе подробно описывается связанная ошибка в теле http. Как я могу получить доступ к этим данным в запросе dojo.Доступ к HTTP-телу по ошибке запроса Dojo
Например, ошибка HTTP выглядит следующим образом:
HTTP/1.1 500 Internal Server Error
Transfer-encoding: chunked
Content-type: application/json
Date: Tue, 18 Sep 2012 18:47:31 GMT
15
This is my exception!
0
Мой Dojo запрос выглядит следующим образом:
require(["dojo/dom", "dojo/on", "dojo/request",
"dojo/json", "dojo/domReady!"],
function(dom, on, request, JSON){
// Results will be displayed in resultDiv
var resultDiv = dom.byId("errorResult");
// Attach the onclick event handler to the makeRequest button
on(dom.byId('errorButton'),"click", function(evt){
request.get("./rest/test/error", {
// Parse data from JSON to a JavaScript object
handleAs: "json"
}).then(function(data){
resultDiv.innerHTML = "Username: " + data.name + "</br>Role:" + data.role;
},
function(error){
// Display the error returned
resultDiv.innerHTML = error;
});
});
}
);
Отображаемая ошибка в это:
RequestError: Unable to load ./rest/test/error status: 500
И что я хотел бы иметь текст в теле:
This is my exception!
Работает как шарм! Благодаря! – Reini