Ticket #315 (new enhancement)

Opened 3 years ago

submitError called after returning string instead of JSON

Reported by: sdm Owned by: mpo
Priority: minor Milestone: 0.5
Component: modules/kauri-forms Version:
Keywords: Cc: kauri-discuss@…

Description

My form has the following events specified:

myForm.submitSuccess = function(data, success){
...
};
myForm.submitError = function (request, status, error) {
...
};

When I submit this form, the following JAX RS method is executed:

@PUT
@Path("test")
@Produces("text/plain")
public String test(String data)
{
    return "3 of 5 tests were successful.";
}

This method succeeds and returns a 200 OK status, but yet the submitError is called because the result of this method is a regular string and not JSON. If I change this string to a JSON object like this:

    return "{test: '3 of 5 tests were successful.'}";

submitSuccess is called as expected.

It seems rather strange that submitError is called, even though the status is 200 OK (everything succeeded server side). Maybe instead of calling submitError, some other error message could be shown to indicate that the method result was not a JSON object?

Note: See TracTickets for help on using tickets.