Hi,
I have a JQuery client and a Servlet server side java apps. My client app looks like this:
url: 'auth',
type: 'POST',
data: data,
dataType: 'json',
cache: false
}).done(function(data, textStatus, jqXHR) {
console.log("Login successful");
router.loggedIn = true;
router.navbar.collection.push([{
id: "logoff",
name: "Logoff"
}]);
Backbone.history.navigate("user", {
trigger: true
});
}).fail(function(jqXHR, error, exception) {
var retry = jqXHR.getResponseHeader("RetriesLeft");
router.loggedIn = false;
$('#loginError').css('color', '#ff0000');
console.log("Login error: " + jqXHR.status);
console.log("Login error: " + error);
console.log("Login error: " + exception);
});
I would like to return from the servlet to the client some arbitrary object with the fields indicating the reason for the failure (in fail handler) or success (in done event).
I thought the easiest way is to set a header (name/value pair) in HttpServletResponse object on the server side and retrieve it using getResponseHeader method on the client side (JQuery) , but this method is described in JQuery doc as kept only for backward compatibility.
Is there any other way of returning an object with additional info from the server back to JQuery client?
Regards,
Janusz