I am currently running an Ajax request to a PHP DB script every 3 seconds, and I need to make a decision based on the result returned. The result is a timestamp. Let's say the ajax request is fired two times. I want to compare the first result with the second result. If they match, I need to do one thing; if they don't match, I need to do something else.
success:function(msg){
console.log(msg);
}
I have attempted to define another variable and store the value of msg
in it to compare with the next value of msg
, but the variable ends up changing along with the value of msg
.
How can I retrieve both the previous and next values simultaneously for comparison?