Web design/development - alternative to manually refreshing the page? - browser

I wonder if there is a better way to write my PHP sites without always having to manually refresh the page I'm working on. Could there be a program that monitors a folder and automatically refresh my browser whenever a change occurs. I'm developing on a local machine with a local amp stack by the way.

You can achieve this by ajax. In ajax you can check the changes in database if any new record added you can call
location.replace('');
in ajax success

Use Ajax poll (checking for status change on server with time intervals) and when the change occurs, either refresh the page with Javascript or replace the part of it to reflect the change.

Related

Website comes up as soon as I start typing

I have an application in Node/Express that is exhibiting some strange (to me, at least) behavior. I am not sure why this happens, but as soon as I begin typing in the URL, the web page instantly comes up. All the logs start populating data and I have my home screen. This is on a local instance for now as I'm still trying to work out bugs related here. I believe these two may be inter-related, but I can't find any data online; perhaps I'm using the wrong search terms, but the long and the short of it is this:
I'm connected to a VM (CentOS7) and everything is run through AWS. I type in my IP:PORT (e.g. 12.34.56.78:9999). As SOON as I type the '1' in the URL, all the logs fire, running through all the scripts. Since I'm at my home page, I hit 'Enter' and is SUPPOSED to go through a redirect to an authorization page (e.g. 12.34.56.78:9999/auth). At that point we're running into my original post, identified above, but this question is simply an attempt to understand why my web page is being shown before I ever 'finish' the call by hitting the 'Enter' key. Is this normal behavior when an application is being accessed locally?
Because your browser is "smart" and guesses that you want to open that website and will therefore load it before you complete the url. That of course only happens if you have previously visited that site, otherwise the browser does not know the url yet. What logic the browser internally uses for this decision depends mostly on the browser and its settings, wether it factors in how recently you visited it or how often, or ...
If you actually want to browse that website when you finish typing the browser has already loaded the page and can instantly display it instead of now loading it and letting you wait a couple of seconds. If you decide you want to go to 123.com instead the browser simply discards the preloaded page and continues as normal.

hood.ie with couchDB method to refresh pages with DB change

I've started using hood.ie to make a web app.
I wanted to ask is there a convenient way to refresh pages whenever data in the couch db changes?
Thanks.
If you have a function that renders your page, like render, you can do this
hoodie.store.on("change", render)
The "change" event will trigger every time something changes in your data, be it because you called on of the hoodie.store APIs, or because of a changed synced from remote

Node/Express app find onhashchange event handler

I'm working on a Node.js website, I've taken the work on for a charity and I confess I'm learning on the job.
The page in question starts with content rendered, but invisible. When you click a button that redirects to a URL starting with a # ( which means it gets appended to the page ), no get occurs, but the content is revealed . The issue is, it needs to be filtered. However, I cannot figure out what is triggering this. The word 'hashchange' does not occur in the code base. The window.onhashchange event is null. Where would I look to try to track down the code that is doing this ?
The content after the hash mark is called an URL fragment. URL fragments are not sent to the server and appending an URL fragment does not typically invoke a page fetch, so it makes sense that no get occurs.
URL fragments are commonly used to keep track of navigation state on the browser side. This is common with single page apps (SPA) that will only fetch the entire page from the server once, and handle the rest of navigation using javascript, pushState, and AJAX queries.
This is presumably what is happening when you navigate to different tabs. The client side javascript is appending URL fragment in order to push state onto the browser history without forcing an unnecessary page reload. Note that this code does not need to listen to the onhashchange event in order for this to work, which is why you don't see any mention of it in your code search.

clearing browser history using jquery/javascript

I am having an application where there will be lots of ajax calls and jquery load functions etc.I found that dynamic content is not loaded correctly every time i open the page due to browser history,if i delete the history and refresh the page its working fine.now
is there any way to clean up the history of the browser?(is this method correct?)
Can i prevent the page from being cached????using any jquery code.so that my application wont be stored in browsers history.
you need to set cache to false in your jquery ajax settings
see here

xPages making continues requests to the server after rebuild

I have a problem with xPages after rebuild, if a user tries to access a page after a rebuild the webpage starts to make continues requests to server, The application uses extlib and the dyamic content control.
The big problem here is that if you are making interval ajax request in the webpage, the same problem will happend without user actions. So all users having the webpage open after a new design is added will automatically get this problem which could probably kill the server.
I am not sure, but I think this might be a Extension Library problem
There is a youtube video of the problem here:
http://www.youtube.com/watch?v=y15XLtWsq80&feature=youtu.be

Resources