AJAX response string comparison

AJAX response string comparison

Hi,

i am so frustrated from 3 days. i am using html, php and ajax for read file, a line each 2 seconds and compare it with string. The String compare doesn't work and i don't know why...
this is my php code
CODE Script.php:
----------------------------------------------------------------------------------------
<?php
if (!$p_file = fopen("inputfile.txt","r")) {
echo "Spiacente, non posso aprire il file miofile.txt";
} else {
$linea = fgets($p_file, 255);
echo "$linea<BR>";
fclose($p_file);
}
$content = file('inputfile.txt');
array_splice($content, 0, 1);
file_put_contents('inputfile.txt', $content);
?>
---------------------------------------------------------------------------
and this is my javascript inside html with ajax
------------------------------------------------------------------------
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script type="text/javascript">

function updateTopic() {
      $.ajax({
        type: "POST",                  
        url : 'script.php', 
        dataType: "text",
         success: function (data) {       
          $("#risultato").html(data); 
         // var $html = $.trim(data);
         // var $document = $.parseHTML($html);
         // var mah=data.toString();
             if( $.trim(data) == "ok"){
              ....my code....
          }
        }
      });
    }

 setInterval("updateTopic()", 2000);
</script>
-------------------------------------------------------------------------------
can anyone help me?
thanks Roberto