[jQuery] Putting data from load() to a variable?
Hey.. I'm having some problems to put the data from the load()
function to a variable. I'm currently using the code below but I need
some modifications to it.
function updateTimer(object_id) {
$("#timer"+object_id).load("checkchanges.php?object_id="+object_id);
setTimeout("updateTimer("+object_id+")", 1000);
}
As you see it puts the checkchanges.php's data to the span called
timerX but I want to put the same data to a variable, how can I do
this? Someone already suggested me to do it like this:
$.ajax({
type: "GET",
url: "checkchanges.php?object_id="+object_id,
success: function(msg){
variablex=msg;
}
});
But that's useless, because the variablex is stuck inside the unnamed
function and therefore useless.