views:

42

answers:

1

Hi, I have a script that looks like this :

<script type='text/javascript'>
$(document).ready(function(){
   setInterval(function() {
   $.ajax({ 
              url: "../Ps/th.php",
              ifModified:true, 
              success: function(data, textStatus){
   if(textStatus!="notmodified") {
   $("#display").append(data);
   alert(textStatus);
   }
   }});


  },1000);
  });
        </script>

and corresponding php is just this :

<?php
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT, true, 304");
echo "shrinath<br>";
?>

the ifModified header seems to be not working as documented (known bug/whatever).

How do i make sure that the ajax doesn't append the data if it is not changed ?

A: 

its a bug in 1.4.2 : http://forum.jquery.com/topic/jquery-1-3-2-update-to-1-4-2-ifmodified-option-doesn-t-still-work

EDIT : hey i think php script is wrong check it out here : http://helpdesk.toitl.com/?w=ajax_ifModified check the loaded.php and index.html on the top right corner

jknair
I know it is a bug, I just wanna know if any brilliant thinkers here can come up with a good workaround here :)
Shrinath
you could echo gmdate("D, d M Y H:i:s") in a hidden div and use it for success method compare the values and then choose to append or not
jknair
could you post an example ? (just being lazy :) )
Shrinath
man, even then, his example too isn't working.. even after you modify the content it doesn't change... and atleast once it should show the modified content right ??
Shrinath
never mind, I did with a work around.. Not exactly the required type, but serves my purpose... I wanted to show the log of a server process, from a txt file, so I created a file reader script, now I am just reloading the data, not appending it...
Shrinath