dscrb00804 2013-06-14 04:57
浏览 654


I need some help with this code, I have found some similar issues:

Uncaught TypeError: Cannot read property 'value' of undefined

Uncaught TypeError: Cannot read property 'name' of undefined

Ajax call in jQuery - uncaught typeerror cannot read property 'error' of null

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 "some value" of undefined"

Jquery code:


function inicio(){

  /*Change pages events*/
  var buttonscan;
  buttonscan = $('#button_scan');


function solicitardatos(){
           var idscan = "001";
                type: 'post',
                //with localhost works fine, this is the ip of my cpu when testing from
                //other device
                url: "",
                data: {datos:idscan},
                cache: false,
                success: function(data) {



            error: function(jqXHR, textStatus, errorThrown) {
                console.log("Error... " + textStatus + "        " + errorThrown);
                alert("Error... " + textStatus + "        " + errorThrown);
            dataType: 'json'


And this is the PHP server file (info.php)

header('Content-Type: text/javascript; charset=UTF-8');

error_reporting(E_ALL ^ E_NOTICE);

$id = $_POST['datos']; 

/*Here is all the sql statements, and the mysqli query*/

while ($fila = mysqli_fetch_array($peticion)) {

    $resultado[] = array("pl"=>$fila['pl'],"name"=>$fila['name']);  

//echo json_encode($resultado);
echo $_GET['jsoncallback'] . '(' . json_encode($resultado) . ');';


So when I use the url setting (localhost) it works, when I change to the server ip ( it stops working and shows: "Uncaught TypeError: Cannot read property 'pl' of undefined"

, I know that the ip it is working because when I copy at my browser it doesn't shows any error


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

  • 写回答

2条回答 默认 最新


      相关推荐 更多相似问题


      • ¥15 结构体数组文件读取问题
      • ¥15 写c++代码,第7题说一下使用的计算方法
      • ¥15 postman接口自动化测试报告实践总结
      • ¥15 有关c++的问题,利用相关知识
      • ¥15 求香农编码和解码的matlab代码
      • ¥20 ROS中的TEB局部规划问题
      • ¥20 关于#matlab#的问题:要求测出上面图片中所有同心圆的半径
      • ¥20 epanet软件运行问题
      • ¥15 Python 文件读取
      • ¥60 dpabi进行Alff计算时脑池有干扰信号