I'm trying to verify if a XML document got modified after I loaded my page, like maybe every 30 seconds. I obtain the xml by making an AJAX request, and preferably, I want to compare the new one and the previous one before calling a function that displays the content into my HTML. How would I do?
 $.ajax(url, {
     method: "GET",
     type: 'xml',
     success: function(content){
         // Verify if the new xml content is the same as before, else 
         useContent(content, idContent)
     }
 });
What I tried:
success: function(content){
    if(previousXML === content) {
        return true;
    } else {
        previousXML = useContent(content, idContent);
    }
}
And this is how I return the content of the function useContent
 function useContent(xmlContent, id){ 
...
return xmlContent}
My current attempt which doesn't work:
if(previousXML === $thisBuildDate){
                    return true;
                } else {previousXML = useContent(content, idContent);
function useContent(xmlContent, id){
    let $lastBuildDate = $(xmlContent).find('lastBuildDate').text();
  return $lastBuildDate
}
I don't understand why it doesn't work since they're equal in my console, but else {previousXML = useContent(content, idContent); is still always executed.
 
    