finsh AJax

<html>  javascript

<head>  php

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />html

<script type="text/javascript" src="js/jquery-1.7.1.js"></script>java

</head>  mysql

  <script type="text/javascript">jquery

  $(document).ready(function(){ sql

   alert(11111);  json

    $("#btn").click(function(){  session

        $.post('blodslect_json.php',{q:'a'},function(result){ app

alert(result);

            $('#disp').html(result)  

        })  

    });  

}); 

  </script>

<body>  

<div id='disp'></div>  

<button id='btn'>enter</button>  

</body>  

</html> 

-------------------blodslect_json.php-----------------

<?php

 session_start();

 include_once("conn.php");

$q=$_POST['q'];  

$i=0;

   // $sql="select g.goodsName, g.goodsPrice,g.goodsCounts,g.goodsDsep,g.goodsImg,r.atterName,t.typeName from goods g inner join goods_atter r on g.atterId=r.atterId 

  // inner join goods_type t on g.typeId=t.typeId where g.goodsName like '%燕%'";

  $sql="select atterName,atterValue from goods_atter";

  $result_db= mysql_query($sql,$con);

  while($getceleck_db = mysql_fetch_array($result_db)){

  $array[$i]['Name']=$getceleck_db['atterName'];

  $array[$i]['Value']=$getceleck_db['atterValue'];

  $i++;

  }

  function arrayRecursive(&$array, $function, $apply_to_keys_also = false)

{

    static $recursive_counter = 0;

    if (++$recursive_counter > 1000) {

        die('possible deep recursion attack');

    }

    foreach ($array as $key => $value) {

        if (is_array($value)) {

            arrayRecursive($array[$key], $function, $apply_to_keys_also);

        } else {

            $array[$key] = $function($value);

        }

 

        if ($apply_to_keys_also && is_string($key)) {

            $new_key = $function($key);

            if ($new_key != $key) {

                $array[$new_key] = $array[$key];

                unset($array[$key]);

            }

        }

    }

    $recursive_counter--;

}


function JSON($array) {

arrayRecursive($array, 'urlencode', true);

$json = json_encode($array);

return urldecode($json);

}

  //$count=count($getceleck_db);

 // echo $count;

 // $list = json_encode($list);

  //echo $list;

  $show=JSON($array);

  echo $show;

  echo $q;  

  echo "<input type='button' value='btn'>";  

?>  

相關文章
相關標籤/搜索