call php file from javascript -
hi have searched web can't work. i'm trying call file databaseupdated.php (placed in same folder index.php file) function called every 10 seconds.
if place following in index.php
<script type='text/javascript'>updateboolean();</script>; the function runned thats not problem, problem php file not read.
the file databaseupdated.php
<body> <?php echo ("<script type='text/javascript'>updateboolean();</script>;"); ?> </body> and here functions in javascript
$(document).ready(function(){ setinterval(function() { $.get("databaseupdated.php");//can't work obvious reason (and yes have jquery working)? return false; }, 10000); }); function updateboolean(){ alert("database updated"); document.location.reload(true); } thanks in advance =)
edit
_________________________________________________________________________________________
when do
alert(data); in below function result image show
$(document).ready(function(){ setinterval(function() { $.get('databaseupdated.php', function(data) { alert('load performed.'); alert(data); eval(data); }); }, 5000); }); 
but "eval(data)" doesn't seem work
$.get("databaseupdated.php"); // return contents of file scripts in file not executed. execute them need eval(). try $.get('databaseupdated.php', function(data) { eval(data); }); also, may require change php file following:
echo ("updateboolean();");
Comments
Post a Comment