Jump to content

Problem with jquery .get ( Only update div when data has changed )


lynxus

Recommended Posts

Hi Guys,

I have the following code.

 

I have a div named data that gets filled in by the data from data.php

How can i get it so it ONLY updates that div when the data is different as currently it doesnt.

 

It seems to update even though its the same ( If i have something selected in teh div, it will de-select when it updates ( although the html is the same ))

 

Thanks in advance.

 

<script language="javascript" type="text/javascript">
<!--
function getdata() {

$(document).ready(function(){
                      
    $.get("data.php", function(result){

    if(result !=  $("#data").html())
    {
        $("#data").html(result);
    }
    
  });
});

}
//-->

var timer = null;
timer = setInterval('getdata()', 2000);
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.