title: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data laravel
body: <p>Hello I have a problem when I wanna show my query result at my text fields 
  I tried to don't use JSON.parse but when I do it this doesn't show anything then I use an alert and show my <strong>undefined</strong> 
  this is the code using an alert to show the result</p>
  
  <pre><code>$(document).ready(function(){
      $('#zip_code').blur(function()
      {
          var zip_code=$(this).val();
          if(zip_code != '')
          {
              var _token = $('input[name="_token"]').val();
              $.ajax({
                  url:"{{route('complete.zip')}}",
                  method:"POST",
                  data:{zip_code:zip_code,_token:_token},
                  success:function(data)
                  {
                      alert(data.value1);
  
                  }
              });
          }
      });
  });
  </code></pre>
  
  <p>when I try to convert the JSON in the console show me it
  SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
  this is the code </p>
  
  <pre><code>$(document).ready(function(){
      $('#zip_code').blur(function()
      {
          var zip_code=$(this).val();
          if(zip_code != '')
          {
              var _token = $('input[name="_token"]').val();
              $.ajax({
                  url:"{{route('complete.zip')}}",
                  method:"POST",
                  data:{zip_code:zip_code,_token:_token},
                  success:function(data)
                  {
                      var result = JSON.parse(data);
                     $('#estado').val(result.value1);
                     $('#municipio').val(result.value2);
  
                  }
              });
          }
      });
  });
  </code></pre>
  
  <p>the PHP files is the next 
   use DB;
  class ClientBusinessController extends Controller
  {</p>
  
  <pre><code>public function index()
  {
  
      return view("new_client.register_business");
  }
  
  public function receiveValueZip(Request $request)
  {   
      if(!empty($request-&gt;get('zip_code')))
      {
  
          $result=DB::table('direccion')
          -&gt;select('Calle1','Calle2')
          -&gt;where('Id_Direccion','=',6)
          -&gt;get();
          foreach($result as $r)
          {
              json_encode(array("value1"=&gt;$r-&gt;Calle1,"value2"=&gt;$r-&gt;Calle2));
  
          }
      } 
  }
  </code></pre>
  
  <p>Does someone know how to resolve this problem? thanks so much </p>