Well I've done a script here to fetch information from the real-time database, but it works fine if I add it directly to MySQL, but it works fine on the page when I insert text it works for MySQL and if you disable script long polling it already adds the database well
Ajax long polling
<script language="javascript">
var timestamp = null;
function cargar_push()
{
$.ajax({
async: true,
type: "POST",
url: "ajax/funcao.php",
data: "×tamp="+timestamp,
dataType:"html",
success: function(data)
{
var json = eval("(" + data + ")");
timestamp = json.timestamp;
opiniao = json.opiniao;
if(timestamp == null)
{
}
else
{
$.ajax({
async: true,
type: "POST",
url: "ajax/mostra_posts.php?id_estabelecimento=<?php echo $row->id; ?>",
data: "",
dataType:"html",
success: function(data)
{
$('#mostra_posts').html(data);
}
});
}
setTimeout('cargar_push()',1000);
}
});
}
$(document).ready(function()
{
cargar_push();
});
</script>
Script that adds post
<script type="text/javascript">
$(function() {
$(".submit_button").click(function() {
var textcontent = $("#opiniao").val();
var dataString = 'id_estabelecimento=<?php echo $row->id; ?>&user_id=<?php echo $_SESSION['user_id'] ?>&opiniao='+ textcontent;
if(textcontent==''){
alert("Por favor escreva uma opinião..");
$("#opiniao").focus();
}else{
$("#flash").show();
$("#flash").fadeIn(400).html('<span class="load">Aguarde por favor..</span>');
$.ajax({
type: "POST",
url: "ajax/processa_post.php",
data: dataString,
cache: true,
success: function(html){
$("#show").after(html);
document.getElementById('opiniao').value='';
$("#flash").hide();
$("#opiniao").focus();
}
});
}
return false;
});
});
</script>