0

I am using a PHP variable to load a part of the view, here is a part of the code

<div id="container">
<?php echo $view ?>    //$view has view loaded in it 
</div>

on a button press I update the innerHTML of the continer through ajax call.

But the problem is that, when I navigate on my site (through forward and backward arrows), and come back to this view, the old value of PHP variable is loaded again, and ajax updates disappear.

What is the best way of updating this PHP variable?

user2969426
  • 119
  • 1
  • 10

2 Answers2

1

I'd say by setting a session or cookie to save the ajax call on the serverside. Then in your controller check for the session, and if it doesn't exist show the initial view.

0

On your ajax call, on server-side, you are returning the new value. You should also update the php variable source (a session variable, database, etc). This way, when the page is loaded again, the variable $view will have the proper value.

nelsonec87
  • 106
  • 6