douran9707 2013-05-29 14:45
浏览 61
已采纳

不返回JSON数据

The problem is that the alert message "TEST" does not appear, although the function getData.php is successfully executed and returns some data. I checked it in Firelog, where I can see the following output:

Array{"arr":[["1","EZY14ZM","2013-05-29 16:44:38","2013-05-29 16:45:28"],["1","VLG1307","2013-05-29 16:47:05","2013-05-29 16:47:55"],["1","WZZ212","2013-05-29 16:49:12","2013-05-29 16:50:02"]],"dep":[["1","VLG8306","2013-05-29 16:59:17","2013-05-29 17:00:00"],["1","VLG3786","2013-05-29 17:07:29","2013-05-29 17:08:12"],["1","IBE1851","2013-05-29 17:08:38","2013-05-29 17:09:21"],["1","DLH58Y","2013-05-29 17:09:47","2013-05-29 17:10:30"]]}

How to solve this problem?

function show_data() {
 $.getJSON(
    'h_index.php?module=mod_1&pag_mod=getData.php',
    function(data) {
       alert("TEST");
    }
 );             
}

getData.php

<?php
   //...
   echo json_encode(array('arr' => $rows_arr, 'dep' => $rows_dep););
   die();
?>
  • 写回答

1条回答 默认 最新

  • 普通网友 2013-05-29 14:50
    关注

    Quote: your data as viewed in Firebug:

    Array{"arr":[["1","EZY14ZM","2013-05-29 16:44 .....
    

    Note the Array at the start of that..... this is not valid JSON.

    The actual json_encode() function you're calling is fine. It does have an extra stray semi-colon, but that's invalid PHP syntax, so I assume it's crept in when you posted the question rather than being in your actual code.

    So the stray text Array is not being produced by the json_encode() function, so it must be coming from somewhere else in your PHP. Look for an echo or a print elsewhere in your code that is outputting it by mistake. (probably by printing an array variable rather than the actual string "Array")

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本