Reload page if Database changes [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I can't set a javascript timer to reload the page every X seconds. It must be a perfect loop with no wait times.
I can't use AJAX. When the database changes a full screen video must be played, and there's no way I can load an "auto-fullscreen" HTML5 video from AJAX method through someotherfile.php
I spent 6 hours today trying to find a way to do this. Apparently I can't put PHP in a loop to 'listen' by doing sql queries every now and on. Weak language I guess.

It has nothing in common with PHP weaknesses it's about server side and client side.
Answering your question. You should try using HTML5 server sent events check these links it should clarify you how to do it. There are examples given:
http://www.w3schools.com/html/html5_serversentevents.asp
https://developer.mozilla.org/en-US/docs/Server-sent_events/Using_server-sent_events
BTW you don't need reload page with JavaScript just simple meta referesh does this.
Note: using EventSource is not supported by all browsers.

Related

I want to add the button of screenshot of my customer's page and then want it to save in a database and show it in a another page as dashboard [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I tried using java script but it didn't work. I also tried php imagegrabscreen() but it demands URL whereas I have a customer's page URL different for everyone ex: /member.php?email=shady#gmail.com&code=A101_123 .
Basically I want to store user's screenshot so he can be able to see those images of his activity. So any solution?
I would recomment to take a look at html2canvas. It is a JavaScript solution that works on the client side. Only problem: It takes the current DOM from the user and builds a picture with the browser engine. So it is not 100% accurate, but pretty close.

How often should AJAX reload specific content on the page? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm constructing an app where users can insert their preferences in a table. It is possible to load an updated version of the table via AJAX. I would like to load these updated versions from time to time, so the users will see almost always the newest version of the table, without reloading the page by themself. My questions regarding that are:
How often should the browser of the user request via AJAX a new version of the table?
Is that a bad approach? Maybe users want to reload the page manually.
Thank you for any answer in advance. Let me know how I can improve my question.
You should probably do it anywhere between 5 and 15 seconds. It's not a bad approach, and you can add a "refresh" button for manual refreshing. If your server is shared or there's lots of traffic, you can increase the duration to 30 seconds.
Note: This answer is based on my experience with web apps and previously built applications and web sites. There are no set standards for this behaviour.

Javascript + PHP timed actions [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Here is my goal:
Create some JavaScript action (some function call) that will be timed perfectly between two different clients.
Explanation:
I want a function to be called exactly on the same millisecond on two different browsers/computers no matter when the client accessed the web page.
I thought about creating a time base using the server time but im not sure this will work.
I think you should be using something Node.JS or APE (Ajax Push Engine) to achieve this.
so you want to do like this scenario: user come visit your webpage and he has to wait few seconds that page is shown?
This is useless to do in my opinion, unless you want to flood server with tons of requests..

What is realtime api that Facebook or Twitter use to show news feed update? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm wondering and don't think they use AJax such as setInterval() to request to the server every seconds. This isn't good way if there are million of users request in same time. What exactly is the tool they are using? It may socket.io or XMPP?
But I've seen in left slider bar listing name of online friends they might use this because when a connections was lost message show "reconnecting in 3,2,1 second(s)".
I asked this question because I don't want to use a lot of requests from clients like this.
MY JAVA SCRIPT
</script>
function getupdate(){
$('#newsfeed').load('getnewsfeed.php');
$('#notify').load('getnewnoti.php');
$('#message').load('getnewmessage.php');
}
setInterval( "getupdate()", 5000 );
</script>
Some divs don't update I don't know why. Ajax load doesn't support multi-load call?
Help or suggest will be truly appropriated. Thanks in advance.
I doubt that this is one "API" or one method to do the live updates, but I can tell you about a few techniques that I know of to direct you in the right direction.
Javascript setInterval() might work but it would not be ideal for this goal.
However there is a more complicated approach which is HTTP persistent connection http://en.wikipedia.org/wiki/HTTP_persistent_connection
Another is the HTML5 Server-sent events, using javascript listens to page update from the server. See this: http://www.w3schools.com/html/html5_serversentevents.asp

I want to listen to changes on the server and update my web page accordingly. How can I do this with Javascript? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am building a web page that pulls data from a server and displays it. The data can change and I want to be able to change the data on the webpage without refreshing the page and not use setInterval. How can I do this with Javascript? Can this be done with Backbone.js?
Thanks
you could use a setInterval that goes to the server and pulls new updates and update the DOM.
If you're using HTML5 then use web sockets which will actually have the server push the updates to the connected client.
If you're writing in .NET then I really really recommend checking out SignalR which will make life easier.

Categories

Resources