4
I have a method in my controller that is called through ajax. It populates a global variable within that controller.
Is there any way I can access this global variable already populated by the first method if I call another ajax method on the same page and controller?
The ultimate goal: This variable would be a large list of data that are generated randomly. So I want in the first generate method. The person sees the data and if she gives ok she goes back to the controller with these same data and does another action with them.
Have you ever tried to put on a Tempdata ? I don’t quite understand your context
– Rod
Give more details of what you want to do. Sometimes you may have more than one solution to your case. Example: save the information in the browser’s localStorage, if you use Angular you can use the
$rootScope
(but the information is lost in the refresh page), etc– Dherik
I was left with the msm doubt when he posted, whether it was angular or not but it is on the server side that he is using and not the client the global variable.
– Renan Degrandi
Why do you need this global variable? Sometimes your error is in the way you try to solve the problem.
– Cleiton