刷新SetInterval js

I have a chat that sends data to the database, I want to load each time the last message not all so on each message I gave it an id that I want to retrieve with .attr see code but .attr referral that 1

   setInterval("load()", 5000);

     function load(){

        var last = $('#last_message span:last').attr('id');

        if(last> 0){
         $.ajax({
            url : '/ajax/public_load.php?id_m=' + last,
            type : 'GET',
            dataType : "html",
            success : function(data){
               $("#last_p").append(data);
            }
         });
      }
   };

<div class="" id="last_message">
  <span  id="<?=$public->chat_id?>" class="summary" style="margin-top: -11px;">
    <?= $public->contenu ?>
  </span>
</div>

</div>

The function attr return a string (the id of the tag), when you try to compare the id with a number javascript try to cast the value "chat_id?>" and obtains a NaN, the result of compare NaN > 0 is false, the code of condition will not be executed.

picture 2image 1

see pictures

//here the message
//i want to recover this exact id but butt .attr 1 each time