1

我有一个 php 脚本,它返回我在 android 中用来加载列表视图的 JSON 响应。我现在想在黑莓中实现相同的功能,但在解析 JSON 响应时出现错误。

响应响应的 php 脚本摘录如下:

                 <?php
                  $response=array();
                   include 'connect.php';
                   $cat=mysqli_real_escape_string($link,$_POST['category']);
                 ------------
                   array_push($response["items"],$item);
                   echo $json_encode($response);
                   ?>

我在黑莓模拟器上得到的响应是这样的:

      <!DOCTYPE  html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
       <head>
       <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
       <title>Untitled Document</title>
      </head>
      <body>
      </body>
      </html>
      {"items":[{"id":"1","item_name":"Sparkling Wine"}],"success":1}

尝试解析 JSON 响应时,此响应会出​​错。我会喜欢这种格式的共鸣:

     {"items":[{"id":"1","item_name":"Sparkling Wine"}],"success":1}

没有多余的标题。我在另一台机器上使用完全相同的脚本,它完美地适用于 android 开发。唯一的区别是我使用 XAMPP 作为我的网络服务器,而在当前机器上我使用 WAMP。我需要知道是否是 WAMP 服务器混淆了我的响应。需要帮忙。谢谢。

4

0 回答 0