Currently I am working on one project, that is a little complicated for my programming capabilities, so the general idea might be wrong. I need to do just one more thing to make everything functionable. I am using local storage in order to temporarily save data from page1.php and after that, display data on page2.php. But when I load page2.php, there is no data because I did not load page1.php first (it is needed to send data to local storage).
The user for his needs does not have to load page1.php first and that is a problem.
Is there any way to reload page1.php when any other page is loaded in order to save data on local storage. In JavaScript or PHP. Thanks in advance.
I tried some manipulations with reload() function, but did not find any solution.
Related
I have a single webpage that uses an API to query backend for data, which is returned and plotted in a few figures. Backend is Node.js with Express.
The appearance of the figures is controlled through a set of JS functions that are loaded when the page initially loads.
After the user has been on the page for 30 seconds, I want to ask them to login or register by displaying a modal over the page.
If the login is successful, I'd like to close the modal and have new functionality available to the user, including changing the behavior of the original JS functions that were loaded when the user first arrived. But, I'd like to do this without reloading a new page with a separate set of JS functions.
I'm a relative newbie at this and have been having a hard time figuring out the right way to accomplish this.
I thought maybe there was a way to update the original JS function file by submitting an API get request and using the response to overwrite replace/overwrite the non-authenticated version. Then user would have access to new functionality without having reloaded the page.
But, I can't seem to find anything that would support this as the correct approach, or even whether this would be possible.
Really need help on which direction to go.
Team, We have implemented a single page application, where we are storing some data in root scope to access in other pages of an application. Everything works fine in normal flow. We hit the problem on browser refresh. When user in one of our application pages, if user refreshes the page, whole data is lost from root scope. We tried not allowing to refresh. But, we found that it is not possible and not even able add custom message to notify the user. Now, we are just logging out the user whenever he refresh the page, which is an awkward to user and that too our application doesn't need that much security. So, we are thinking to add whole root scope data in local storage on refreshing the page and after reloading the page, we would again load whole data from local/ session storage data to root scope. We have to do this at single place. So, we don't have to implement this at individual module page.
Is there a way to achieve this. Can any one please suggest if have an alternate way.
Be aware that HTML5 Local Storage only has 800kb-10mb depending on the browser. I heard Safari has 99 idk. 5mb in the latest Google Chrome (2/14/17).
Anyway, you can create a local storage by stringifying to JSON:
localStorage.setItem('myDataStorage', JSON.stringify(myData));
Then retrieve them
var myRetrievedData = JSON.parse(localStorage.getItem('myDataStorage'));
myDataStorage is the name of your created localStorage. You can use different names to create multiple localStorages if you would, just be aware that each one is limited only in size. Don't expect to save HD images much less videos using HTML local storage
That being done, your retrieved data can now be manipulated by your code using the variable myRetrievedData (or whatever variable name you want)
I'm trying to create a button in my website that counts the clicks and saves them to a text file on the server. I managed to make everything else work like it should except sending the data to server.
I tried using PHP but that requires page refreshing and I don't want that.
Basically I need some help on how to overwrite a server text file with a variable (without having to refresh the page)
Is it even possible to do this without using PHP? (Page refresh everytime data is saved)
Thanks in advance.
when the user starts my app, there is a lot of data coming from a web service which is stored into the deviceĀ“s database and then shown on the HTML-page using jquery`s .html() method. The problem is when the user selects another HTML page and then comes back, the data is not shown anymore, it has to be read out from the database again.
I know this isn't "rent a coder" but my question is: Is there a way to keep the data persistant on the HTML page even after the page is reloaded? Or do I have to pack everything into a single HTML document?
The solution could be to handle all navigation with AJAX, make your website a one page app and keeps things into cache. But i think this is a really big topic.
In any case a good Javascript MVC Framework like Backbone or Ember could help you.
I have a online web application form which I have to open every time and have to fill data and Submit.. So, I have got an idea of making a Google Chrome extension, that will make that page stored inside localStorage So that I can access it like a desktop page.. Is this possible.. I do not have any permissions to change the web site at server side.. I am just a client side programmer.. Is it possible? if yes please let me know how can I achieve this..
in theorie, yes, you could. Practically, it won't work out like you want. The reason are the external resources the website is going to be needing.
Storing just the html (document.body.innerHTML) would be possible. BUt if you want the formatting/layout to be happening, you'd need to save the computedStyles for each element as well. And if an image, you'd need to Base64 encode the image and save it.
Even if you'd succeed in saving the page, you'd need to know when to expire your localStorage cache and refetch the resources to stay compliant to the server side parsing of the form data (if they'd change something).
if its just about submitting a form, you also could just trigger the forms post-action-url directly by writing a script that resends the data you want sent.