本帖最后由 maplemm 于 2014-10-25 20:38:26 编辑

解决方案 »

  1.   

    使用ajax即可。
    demo.php<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <title> New Document </title>
      <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
     </head> <body>
      <script type="text/javascript">
      function show(c){
        var id = c.value;
        $.get("server.php", { id: id },function(ret){
            if(ret.success==true){
                alert(ret.data);
            }
        },'json');
      }
      </script>  <?php
      $sportset = array(
        array('name'=>'name1','id'=>1),
        array('name'=>'name2','id'=>2)
      );
      foreach($sportset as $val){
      ?>
      <li class="choosespot" title="点击查看详细信息" value="<?php echo $val['id']; ?>" onclick="show(this)"><?php echo $val['name'] ?></li>
      <?php
      }
      ?>
      <?php ?>
     </body>
    </html>
    server.php<?php
    $id = isset($_GET['id'])? $_GET['id'] : 0;
    $data = array('','数据1','数据2');
    $ret = array();
    $ret['success'] = true;
    $ret['data'] = $data[$id];
    header('content-type:application/json');
    echo json_encode($ret);
    ?>