JSON web服务响应

JSON webservice response

本文关键字:响应 服务 web JSON      更新时间:2023-09-26

我想在我的网页中显示JSON webservice的元素。这是我的服务响应

  {"business":[{
        "businessguid": "http:'/'/www.example.com/uploads/Facebook-ipo.jpg",
        "businessposttitle": "Facebook ipo",
        "omgguid": "http:'/'/www.samplesite.com'/?p=807",
        "omgposttitle":"samplesite title"
    }]}

我尝试用Javascript解析该服务,我的代码是

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
 <script type="text/javascript">
  $(function()
   {
    $(document).ready(function()
     {
     $.getJSON("insiders.php",function(data)
      {
      $.each(data,function(key,value){
      var da ="<div ><a href="+value.businessguid+">"+value.businessposttitle+"</a></div>";
    $(da).appendTo("#data_area");
       });
       }
      );
    return false;
   });
  });
  </script>
 </head>
 <body>
<div id="data_area"></div></body>

但是它没有显示任何我出错的地方…??

<?php
$jdata = "http://www.example.com/myservicefile.php"; //Service URL
$content = file_get_contents($jdata);
$resultdiv = json_decode($content, true);
$businessdata=$resultdiv['business'];
foreach ($businessdata as $key => $value)  {
      echo '<span>'.$value[0].'</span></p>';  
         }
       ?>