大家好,又见面了,我是你们的朋友全栈君。
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<script type=”text/javascript” src=”js/jquery-1.7.1.js”></script>
</head>
<script type=”text/javascript”>
$(document).ready(function(){
alert(11111);
$(“#btn”).click(function(){
$.post(‘blodslect_json.php’,{q:’a’},function(result){
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’>”;
?>
转载于:https://my.oschina.net/u/1042750/blog/189445
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/143392.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...