title: Uncaught TypeError: Cannot read property 'data' of undefined
body: <p>I need some help with this code, I have found some similar issues:</p>
  
  <p><a href="https://stackoverflow.com/questions/6550795/uncaught-typeerror-cannot-read-property-value-of-undefined">Uncaught TypeError: Cannot read property &#39;value&#39; of undefined</a></p>
  
  <p><a href="https://stackoverflow.com/questions/15312479/uncaught-typeerror-cannot-read-property-name-of-undefined">Uncaught TypeError: Cannot read property &#39;name&#39; of undefined</a></p>
  
  <p><a href="https://stackoverflow.com/questions/7868981/ajax-call-in-jquery-uncaught-typeerror-cannot-read-property-error-of-null">Ajax call in jQuery - uncaught typeerror cannot read property &#39;error&#39; of null</a></p>
  
  <p>but still not working,  I'm using jquery (.ajax) to send and recieve data to the server (php), when I use localhost at url in .ajax function, it works fine and receives the data that I need, but when I change the url for the ip of the server it shows: "Uncaught TypeError: Cannot read property <em>"some value"</em> of undefined"</p>
  
  <p>Jquery code: </p>
  
  <pre><code>$(document).on("ready",inicio);
  
  function inicio(){
  
  
  
    /*Change pages events*/
    var buttonscan;
    buttonscan = $('#button_scan');
    buttonscan.on("click",solicitardatos);
  
  
  
  }
  
  function solicitardatos(){
             var idscan = "001";
              $.ajax({
                  type: 'post',
                  //with localhost works fine, this is the ip of my cpu when testing from
                  //other device 192.168.0.101
                  url: "http://192.168.0.101/server/info.php?jsoncallback=?",
                  data: {datos:idscan},
                  cache: false,
                  success: function(data) {
  
  
                  $('#button_scan').hide();
                  $('#page1').hide();
                  $('#page2').show(); 
  
  
                  $('#pl').html(data[0].pl);                 
                  $('#name').html(data[0].name);
  
  
              },
              error: function(jqXHR, textStatus, errorThrown) {
                  console.log("Error... " + textStatus + "        " + errorThrown);
                  alert("Error... " + textStatus + "        " + errorThrown);
              },
              dataType: 'json'
          });
  </code></pre>
  
  <p>}</p>
  
  <p>And this is the PHP server file (info.php)</p>
  
  <pre><code>&lt;?php 
  header('Content-Type: text/javascript; charset=UTF-8');
  
  error_reporting(E_ALL ^ E_NOTICE);
  require("conexion.php");
  
  
  $id = $_POST['datos']; 
  
  /*Here is all the sql statements, and the mysqli query*/
  
  while ($fila = mysqli_fetch_array($peticion)) {
  
      $resultado[] = array("pl"=&gt;$fila['pl'],"name"=&gt;$fila['name']);  
  }
  
  
  
  mysqli_close($conexion);
  //echo json_encode($resultado);
  echo $_GET['jsoncallback'] . '(' . json_encode($resultado) . ');';
  
  ?&gt;
  </code></pre>
  
  <p>So when I use the url setting (localhost) it works, when I change to the server ip (192.168.0.101) it stops working and shows:
  "Uncaught TypeError: Cannot read property 'pl' of undefined"</p>
  
  <p>, I know that the ip it is working because when I copy 192.168.0.101/server/info.php at my browser it doesn't shows any error</p>
  
  <p>Thanks,</p>
  
  <p>Now I have used an external server, which is in cloud, and it works if I use a constant $id = "001" at info.php, but when I removed that constant and put $id = $_POST['datos'] ,is empty again, so I think there is something wrong when sending the data</p>