• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

@ControllerAdvice session data and ajax issue  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using @ControllerAdvice to use shared data accross my application.

It all worked fine until I did an ajax request.

The problem is that the relevant data from @ControllerAdvice is always a step behind.

This is the relevant code from @ControllerAdvice



And my view:


Now, If I use the application normally without ajax, meaning if let's say I add an item to the cart and the page refreshes normally, then it all works as expected, I get the correct values for csize and ctotal, however if I use ajax to hit the appropriate url and then return the view, the csize and ctotal variables are always a step behind, so for example if there are no items added and I add the first item, I don't see a difference via ajax, and then if I add another then the value of csize is 1 (instead of 2), then if I add another it is 2 instead of 3 and so on. But if I refresh the page it is correct.

So basically via ajax the data from @ControllerAdvice is a step behind, any idea why? I mean I basically get "why", because I guess only an html view is returned and there is no real redirect, but can I still achieve proper values somehow?
 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!