localStorage value is not updated with latest value on Load
I have the following code below. I want to first execute a query which writes to a localStorage variable. Then I want to retrieve that value from the localStorage variable. However, the problem is that the localStorage variable that gets evaluated at the time the code runs is a previous localStorage value. It does not update first, as the code has the query to run first before it retrieves a localStorage variable.
pre
var value = localStorage.getItem('dimensions');
var obj = jQuery.parseJSON(value);
....do other stuff with obj
/pre