ajax-polling

PHP Poll with Results on Same Page

拈花ヽ惹草 提交于 2020-01-30 12:06:26
问题 There was a great article posted by CSS-Tricks.com describing how to create a poll using PHP and a MySQL database. I've followed this and created a nice poll for myself. I noticed in the comments a mentioning of using AJAX to show the results on the same page instead of a completely separate page. I am wondering what is the best way to display PHP Poll results on the same page? UPDATE: The answer is really simple. In fact, CSS-Tricks' poll without AJAX in my opinion is more difficult since it

Ajax polling vs SSE (performance on server side)

有些话、适合烂在心里 提交于 2019-12-23 04:43:25
问题 I'm curious about if there is some type of standard limit on when is better to use Ajax Polling instead of SSE, from a server side viewpoint. 1 request every second: I'm pretty sure is better SSE 1 request per minute: I'm pretty sure is better Ajax But what about 1 request every 5 seconds? How can we calculate where is the limit frequency for Ajax or SSE? 回答1: No way is 1 request per minute always better for Ajax, so that assumption is flawed from the start. Any kind of frequent polling is

Trying to call a function every 3 minutes using JavaScript

自作多情 提交于 2019-12-23 01:37:26
问题 I have a function that returns an integer (the current reputation score for a user on a community site). That number is often going up or down based on how their comments and submissions are voted on. I'd like to "poll" it every 30 seconds or so to see if it's changed, and if so, update the number that I'm displaying. In another StackOverflow thread, I found this JavaScript snippet that looked useful: function listen() { $.get("/mylongrequestfile", {}, function(data) { $("#mydiv").html(data);

jquery polling with smart poll plugin

ぃ、小莉子 提交于 2019-12-21 06:01:04
问题 I'm trying for the life of me to get this plugin to work but I'm not understanding the status function so retry is not firing. $.poll(10000, function(retry){ $.get('willfail', function(response, status){ if (status == 'success') { // Do something alert("YES"); } else { alert("NO"); //retry(); } }) }) If I set the get request to '/' it will give me the alert YES message, but as it is, the alert No message never gets fired despite the ELSE. I'm using a jquery polling plugin: https://github.com

How to break out of AJAX polling done using setTimeout

淺唱寂寞╮ 提交于 2019-12-08 10:04:32
问题 I want to implement AJAX polling mentioned in this answer. Now I want to break out of polling when server return particular data value. How to do that? 回答1: Try something like this (where you change the condition to set continuePolling false to whatever you need): (function poll() { var continuePolling = true; setTimeout(function() { $.ajax({ url: "/server/api/function", type: "GET", success: function(data) { console.log("polling"); if (data.length == 0) { continuePolling = false; } },

How to correctly start/stop a PrimeFaces Ajax Poll from javascript

↘锁芯ラ 提交于 2019-12-08 05:55:28
问题 I want a little webapp for testing a connection to a server and returning a status message. After clicking a start button, I want to poll every 4 seconds and return a status text. But it will only return, if I click on the button, not automatically. Here is my code: index.xhtml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http

Trying to call a function every 3 minutes using JavaScript

自古美人都是妖i 提交于 2019-12-06 16:07:26
I have a function that returns an integer (the current reputation score for a user on a community site). That number is often going up or down based on how their comments and submissions are voted on. I'd like to "poll" it every 30 seconds or so to see if it's changed, and if so, update the number that I'm displaying. In another StackOverflow thread, I found this JavaScript snippet that looked useful: function listen() { $.get("/mylongrequestfile", {}, function(data) { $("#mydiv").html(data); listen(); // then launch again })); }; Do I just replace /mylongrequestfile with my function? I'm

angular dot notation better explanation

a 夏天 提交于 2019-12-06 14:18:01
问题 I was looking for a solution about polling data using AngularJS and I found here at stackoverflow. In this solution (shown bellow) it is used a javascript object to return the response ( data.response ) and if I try to replace that data object for a simple javascript array it doesn't work , I would like to know exactly why I need to go with dot notation and why a single array doesn't work? (It would be great links or explanation with examples) app.factory('Poller', function($http, $timeout) {

AJAX/Reverse AJAX: Polling or Push?

痞子三分冷 提交于 2019-12-04 21:20:33
问题 Been studying a ton on AJAX because I'm making a real-time application out of Javascript and PHP. It needs to be able to update without refreshing the page and in real-time. I tried polling the server with setInterval() but for it to be quick I had to have it every second. It seems to be using a ton of bandwidth though. It does work however and I have a plan with my hosting provider for 'unlimited bandwidth'. It seems like a lot of stress on the site though so I wanted to use a Push

angular dot notation better explanation

北城以北 提交于 2019-12-04 20:29:56
I was looking for a solution about polling data using AngularJS and I found here at stackoverflow. In this solution (shown bellow) it is used a javascript object to return the response ( data.response ) and if I try to replace that data object for a simple javascript array it doesn't work , I would like to know exactly why I need to go with dot notation and why a single array doesn't work? (It would be great links or explanation with examples) app.factory('Poller', function($http, $timeout) { var data = { response: {}, calls: 0 }; var poller = function() { $http.get('data.json').then(function