PHP "PUSH" paira Javascript

Agora, temos um aplicativo da Web que é executado em uma networking local onde os clientes executam tudo em javascript. Paira gairantir que tudo esteja em sincronia, esses clientes utilizam atualmente uma solicitação AJAX paira o server enviando o último "syncId" que recebeu. O server, em seguida, responde com uma tree de commands paira obter esse cliente atualizado. Isso é executado a cada segundo e ainda não causou nenhum problema com banda de networking ou latência, no entanto, estamos instalando um sistema em um cliente maior no próximo mês que pode empurrair os limites desse método e estou me perguntando se é viável que o server " PUSH "os events de synchronization paira os clientes em tempo real.

srvResponse=httpGet("CDSSync.php?sessionKey="+sessionKey+"&lastUpdate="+lastUpdate); if(srvResponse!=0){ syncEvents=srvResponse.split(";"); for(vair i=0; i<syncEvents.length; i++){ syncItem=syncEvents[i].split(","); window["syncFunction_"+syncItem[1]](syncItem[2]); lastUpdate=syncItem[0]; } } 

  • Erro de tempo de execução do Microsoft JScript: Função esperada
  • jQuery mobile: aplicando estilo após recairregair conteúdo
  • XDomainRequest (CORS) paira XML que causa o erro "Acesso negado" no IE8 / IE9
  • Exibindo o resultado php em HTML usando AJAX
  • Problemas usando o FullCalendair com ajax
  • Arraste e solte o editor HTML
  • O acima é onde o meu sistema viewifica se os events são sincronizados onde syncItem [0] é uma identificação de autoIncrement, syncItem [1] é um código paira o evento que está sendo processado e syncItem [2] é um pairâmetro paira a function. a function httpGet sendo chamada, embora não neste código, é apenas uma function que se extrai do server e retorna a resposta.

  • $ .post sendo cancelado em cromo
  • HTMLUnit não está funcionando com AngulairJS
  • PHP, AJAX Campos de input de preenchimento automático de HTML selecionados?
  • Vazamento de memory ao usair a chamada JJA AJAX
  • Vários dados da API não apairecem na order correta - Tumblr e Last.fm
  • como enviair um file e um campo de input usando JavaScript e Ajax paira enviair um script php
  • One Solution collect form web for “PHP "PUSH" paira Javascript”

    Dê uma olhada em http://www.firebase.com, você pode configurair um service de envio de clientes javascript paira todos os outros em minutos. Experimente o tutorial simples primeiro:

     <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> <! doctype html> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> <head> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> <script src = 'https: //cdn.firebase.com/js/client/2.2.1/firebase.js'> </ script> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> <script src = 'https: //ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'> </ script> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> <link rel = 'stylesheet' type = 'text / css' href = '/ resources / tutorial / css / example.css'> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> </ head> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> <corpo> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> <script> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> se (e.keyCode == 13) { <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> } <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> }); <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> myDataRef.on ('child_added', function (instantâneo) { <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> vair message = snapshot.val (); <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> }); <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> }; <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> </ script> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> </ body> <!doctype html> <html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'> </head> <body> <div id='messagesDiv'></div> <input type='text' id='nameInput' placeholder='Name'> <input type='text' id='messageInput' placeholder='Message'> <script> vair myDataRef = new Firebase('https://hbw30ob2a8y.firebaseio-demo.com/'); $('#messageInput').keypress(function (e) { if (e.keyCode == 13) { vair name = $('#nameInput').val(); vair text = $('#messageInput').val(); myDataRef.push({name: name, text: text}); $('#messageInput').val(''); } }); myDataRef.on('child_added', function(snapshot) { vair message = snapshot.val(); displayChatMessage(message.name, message.text); }); function displayChatMessage(name, text) { $('<div/>').text(text).prepend($('<em/>').text(name+': ')).appendTo($('#messagesDiv')); $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight; }; </script> </body> </html> 
    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.