-1

I am sending DELETE type Ajax request to my delete method in my controller. For successful delete, I am trying to redirect to another method in same controller that reloads the list and is of GET type.

Currently my delete operation is working fine with default status code 302,but on redirect, it is redirecting with 'Request Method: DELETE' instead of 'GET' which is default behavior of Grails.

Kindly suggest the solution for it

redirect(action: 'list',controller:'dashboard')
Duck Dodgers
  • 3,409
  • 8
  • 29
  • 43

1 Answers1

0

If you want to do a redirect you should be doing an http call rather than an Ajax call. The redirect is handled automatically by your browser so you can't change it from a delete to a get. You might try using a forward or making a separate call to the list in a callback/promise.

Alternatively if you want to keep it in one Ajax call, I would hope that your dashboard controller, list action would be calling a service to get it's data. So instead of doing a redirect I would call that services, and return that data.

I say hope because I've seen many examples, where people put business logic in controllers, where it doesn't belong, instead of moving it to a service, where it can be reused.

virtualdogbert
  • 462
  • 3
  • 12