title: get data with ajax real time in laravel
body: <p>I want to create a ajax notification system with laravel and write code that does it.
  My question is that at this time every single item in the code goes to the page that I need if a new item was created as a result of the AJAX, a value to be added to the previous value.</p>
  
  <p>my code is </p>
  
  <pre><code>$(document).ready(realTime);
  
  function realTime() {
      $.ajax({
          type:'post',
          url:'{{ route( 'getnews' ) }}',
          data:{
              '_token':"{{ csrf_token() }}",
          },
          success: function (result) {
  
  
              $.each(result, function (k, v) {
  
                  $('#payam').append($('&lt;option&gt;', {value: k, text: v}, '&lt;/option&gt;'));
              });
  
              setTimeout(realTime, 2000);
          },
          error: function () {
              //handle errors
              alert('error...');
          }
  
      });
  
  }
  </code></pre>