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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.