0

I use spring boot and jquery.

I do an ajax call.

 var memberId = $('#memberId').val();
 var type = "put";
 var url = getHostName() + "/members/" + memberId + "/payments/" + paymentsId + "/process/" + paymentMode;
 jQuery.ajax({
     type: type,
     url: url,
     contentType: "application/json",
     dataType: 'json',
     success: function (data, status, jqXHR) {
         loadMemberPaymentTable(templateMemberPayment, memberId);
     },
     error: function (jqXHR, status) {
         check401Unauthorized(jqXHR);
     }
 });

This controller is called, and in error is called

 jqXHR = Object {readyState: 4, responseText: "", status: 200, statusText: "OK"}, status = "parsererror"

dont know if its' the spring thing who is the problem or not

@RequestMapping(value = "/members/{memberId}/payments/{paymentsId}/process/{paymentMode}", method = RequestMethod.PUT)
public ResponseEntity<Void> processPayment(@PathVariable("memberId") Long memberId, @PathVariable("paymentsId") List<Long> paymentsId, @PathVariable("paymentMode") PaymentModeEnum paymentMode) {
        paymentService.processPayment(paymentsId, paymentMode);
    return new ResponseEntity<Void>(HttpStatus.OK);
}

Edit

Url called is http://localhost:8080/rest/members/6/payments/100,101/process/CASH

if i return a value from my controller... that work So it's seem the problem it's spring...

Don't seem to be the correct way, to return no value.

process can work or fail... so what is the correct way to send this to the client?

maybe there is something from spring boot to manage that?

robert trudel
  • 5,283
  • 17
  • 72
  • 124
  • Would it be possible to post the final URL that your are hitting, specifically the Enum and paymentIds part - do scrub the host if necessary. – JVXR May 23 '16 at 21:27
  • i edited the question and answered your question. – robert trudel May 24 '16 at 00:35
  • I'd first try logging the arguments before sending them to processPayment and put the processPayment in a try catch block, with the catch returning a 500 and logging the exception being thrown. the Http.OK would be send only if there's no error. – JVXR May 24 '16 at 17:30

0 Answers0