javascript - Replace data only if new content is different -


i started out problem extremely similar one: jquery : remplace content if new content different

i've tried accepted solution, , doesn't seem work way supposed to. tried first native solution, putting in div stuff. tried looking function on jquery's site here: http://api.jquery.com/data/ , fixed code accordingly last example. tried alerting data see going on, it's fair amount of data, why have md5 hashed.

my problem first alert coming undefined, , second 1 is, in fact, defined going out. doing wrong? cause stored data disappear?

my current code:

function setdiv(data) {     newdata = md5(data);     if ($('#mydiv1').data('olddata') != newdata) {         $('#mydiv1').fadeto("fast", 0, function () {$(this).html(data).fadeto("fast", 1)});          alert($('#mydiv1').data('olddata'))          $('#mydiv1').data('olddata',md5(data));         alert($('#mydiv1').data('olddata'))     } } 

and script headers (the second 1 md5 function):

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="http://www.myersdaily.org/joseph/javascript/md5.js"></script> 

for intents , purposes, data being fed function correct... see of it, anyways. still functions after being set. don't want refresh every time settimeout it's thing, plus rather things fading out , in, rather bam.

right now, current code, fades in , out, though data same. , alerts me undefined on start, , md5 on finish. same md5 on finish every time, it's same data. first alert undefined being problem.

function submits data function above:

function loaddivcontent(arg1,arg2) {     $.post('divcontent.php',{arg1:arg1,arg2:arg2})     .done(function(data) {         setdiv(data)     }); } 


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -