Guest User

Untitled

a guest
Jun 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <g:remoteFunction action="list" controller="todo" update="todo-ajax">
  2.  
  3. <div id ="todo-ajax">
  4. //ajax call rendered in this area
  5. </div>
  6.  
  7. HttpServletRequest.metaClass.isXhr = {->
  8. 'XMLHttpRequest' == delegate.getHeader('X-Requested-With')
  9. }
  10.  
  11. if(request.xhr) { ... }
  12.  
  13. if(!request.xhr) {
  14. redirect(controller: 'auth', action: 'index')
  15. return false
  16. }
  17.  
  18. import javax.servlet.http.HttpServletRequest
  19.  
  20. class BootStrap {
  21.  
  22. def init = { servletContext ->
  23.  
  24. HttpServletRequest.metaClass.isXhr = {->
  25. 'XMLHttpRequest' == delegate.getHeader('X-Requested-With')
  26. }
  27.  
  28. }
  29. def destroy = {
  30. }
  31. }
Add Comment
Please, Sign In to add comment