I am not sure what your problem is with this code as it looks like it should work. Are you getting an error or is the logic not working or is the refresh not reloading with new data?
I am not sure if this will help at all, but the location.reload() has an extra parameter, that when set to TRUE reloads the page from the server, otherwise it reloads it from the browser.
Quote:location.reload(forceGet)
forceGet : Boolean
Optional. Specifies the type of reloading:
• false - Default. Reloads the current page from the cache.
• true - Reloads the current page from the server
If this has completely misunderstood the problem you are having, I apologise in advance,
Best wishes,
Paul.