for some reason this code wont work, it doesn’t seem to read the javascript.php file, im trying to make a remote control, ive tried many different scenarios and can seem to get it working, i have a similar script that will change the contents of a div depending on the file contents that seems to work fine, so i used the major components from that script to make this one and it doesn’t want to open the javascript.php file, when the javascript.php file is opened it will read from the mysql database a value of 1-3 and delete the value from the database after the value has been printed
////////////////////////////repeat script////////////////////////////////
var c=0;
var t;
var timer_is_on=0;
function timedCount()
{
c=c+1;
//////////insert/////
check();
/////////insert////////
t=setTimeout("timedCount()",1000);
}
function doTimer(){
if (!timer_is_on){
timer_is_on=1;
timedCount();
}
}
////////////////////////////////////repeat script/////////////////////////////
function check(){
var html = $.ajax({
url: "javascript.php",
async: false
}).responseText;
if (html==1){
jwplayer().play();
};
if (html==2){
jwplayer().setMute();
};
if (html==3){
jwplayer().stop();
};
}
1) WTF? Well, you’ve made an infinite loop by calling that function over and over. And this is by no means how to do a proper ajax request.
2) TO do it proper, just put your conditionals in the response function. Use async, that means it happens asynchronously and wont block your UI from functioning while it makes the request.
3) javascipt.php is a terrible name in terms of code maintenance. Call it what it does.