<html>
<head>
<ti
<sc
</head>
<sc
$.ajax({
type: "get",
url:"index.php?s=/Home/restful/cg",
cache : false,
async : false,
dataType: "json",
success: function(data){
$.each(data, function(key,val){
alert(val.name);
})
}
})
</sc
<body>
<p>this is the information</p>
<div class="mydiv"></div>
</body>
</html>
PHP页面:
Public function cg() {
switch ($this->_method){
case 'get': // get请求处理代码
//获取商品父级类型
$where['pid']=0;
$cg=M('cg')->where($where)->select();
$json_str=json_encode($cg);
echo $json_str;
break;
}
}
html页面ajax成功接收到了返回的信息(json格式),alert()成功弹出信息。
我是想将信息显示在html页面上,不是在alert()中。该怎么写呢。
最佳答案