i have a script that loads some div ids from php and every x seconds reloads the new values.. I want to implement an onchange value inside the script in order to trigger loading a new variable if (in this example artist changes) but i cant figure out how.. the script is:
setInterval(function(){
cache: false,
$("#artist").load("test.php #artist");
$("#song").load("test.php #song");
}, 2000);
I need to tell if artist changes then load a new variable from php, using this wrapper code i found here How can I make a program wait for a variable change in javascript??
function Wrapper(callback) {
var value;
this.set = function(v) {
value = v;
callback(this);
}
this.get = function() {
return value;
}
}
If i use the same example with input box:<input type="text" onchange="wrapper.set(this.value)"/>
it works.. But i cant figure out how to make it work using the #artist pulled from the php in the first part..
I tried doing this :
<script type="text/javascript">
setInterval(function(){
cache: false,
$("#artist").load("test.php #artist").onchange(wrapper.set(this.value));
$("#song").load("test.php #song");
}, 2000);
</script>
and a lot of other combinations but neither works.. Can you help me please!
PS: Keep in mind that im a startet in javascript..
Thank you for your answers.