As stated in the PlayFramework Document 2.0 and PlayFramework Document 2.1, it is known that Play can return various responses such as:
Ok()
badRequest()
created()
status()
forbidden()
internalServerError()
TODO
However, when trying to send a response with additional information using ajax, Play only sends status information along with some mysterious object. Only the ok("Test message")
method successfully includes both status and custom message. How can this issue be addressed?
-- Edit --
An example of an ajax method being used:
$.post($("#assignmentsubmitAddress").text(), { 'units' : submittedUnits },
function(response, status, xhr) {
showNotification(status, response);
})
When using return ok("test");
in the Java script, the variable response
contains the string "test". However, if return badRequest("test");
is used, the response
variable holds a Java object instead and printing it results in displaying Object object
.