Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
59
rated 0 times [  62] [ 3]  / answers: 1 / hits: 25790  / 11 Years ago, fri, may 3, 2013, 12:00:00

Hi I have searched the web but can't get this to work. I'm trying to call the file databaseUpdated.php (placed in the same folder as the index.php file) from a function that is called every 10 seconds.



If I place the following in the index.php



<script type='text/javascript'>updateboolean();</script>;


the function is runned so thats not the problem, the problem is that the php file is not read.



the file databaseUpdated.php



<body>
<?php

echo (<script type='text/javascript'>updateboolean();</script>;);

?>
</body>


And here is my functions in the javascript



 $(document).ready(function(){
setInterval(function() {
$.get(databaseUpdated.php);//Can't get this to work any obvious reason for this (And yes I have jquery working)?
return false;
}, 10000);
});



function updateboolean(){
alert(Database updated);
document.location.reload(true);
}


Thanks in advance =)



Edit



_________________________________________________________________________________________



When I do



alert(data); in the below function I get the result as the image will show



$(document).ready(function(){
setInterval(function() {
$.get('databaseUpdated.php', function(data) {
alert('Load was performed.');
alert(data);
eval(data);
});
}, 5000);
});


enter



But the eval(data)
doesn't seem to work


More From » php

 Answers
3
$.get(databaseUpdated.php); // This will only return contents of that file The scripts in that file are not executed. To execute them you need to do eval(). So Try This

$.get('databaseUpdated.php', function(data) {
eval(data);
});


Also, may be you will require to change your php file as following:



echo (updateboolean(););

[#78449] Thursday, May 2, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dewayneh

Total Points: 538
Total Questions: 114
Total Answers: 97

Location: Liberia
Member since Fri, Oct 22, 2021
3 Years ago
;