ajax获取json的值
2015-12-21 17:04
489 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery.min.js"></script>
<script src="jsScroll.js"></script>
<style type="text/css">
*{margin:0;padding:0;}
ul li{list-style:none;}
.showMoreNChildren{width:195px;margin:0 auto;overflow:hidden;padding-right:10px;}
.showMoreNChildren li {width:100%;position: relative;padding: 8px 0 8px;display:block;}
.icon-putong {width: 34px;height: 34px;background: 0;display:inline-block;}
.showMoreNChildren li span {width: 120px;margin: 0 0 0 10px;display:inline-block;font-size: 13px;cursor: default;padding-top: 1px;}
.groupIcon {background: 0;position: absolute;left: 163px;}
.groupIcon img {max-height: 30px;max-width: 30px;}
.divScrollBar{background-color:#ddd;position:absolute;opacity:0.5; filter:Alpha(opacity=50);}
.divScrollBar:hover{opacity:1; filter:Alpha(opacity=100);}
.divScrollBar div{background-color:#aaa; position:absolute; left:0px; top:0px;}
.divScrollBar{background-color:#ddd;position:absolute;opacity:0.5; filter:Alpha(opacity=50);}
.divScrollBar:hover{opacity:1; filter:Alpha(opacity=100);}
.divScrollBar div{background-color:#aaa; position:absolute; left:0px; top:0px;}
.showMorehandle{text-align:center;font-size:14px;color:#09F;}
</style>
</head>
<body>
<div id="user_list_bar" style="width:204px;margin:0 auto;overflow-y:scroll;height:800px;">
<ul id="users" class="showMoreNChildren" pagesize="2">
</ul>
<div class="showMorehandle">更多..</div>
</div>
<script>
$(function(){
$.ajax({
type: "POST",
url: "/hhh.php",
dataType: "json",
data:"123",
success: function(data) {
var json=eval(data);
for(var n=0;n<json.length;n++){
jQuery("#users").append("<li class=\"login-user\" ><i class=\"icon-putong\"><img src=\""+json
.perimg+"\" width=\"24px\" height=\"24px\" /></i><span>"+json
.name+"</span><i class=\"groupIcon\"><img src=\""+json
.iconimg+"\"
/></i></li>");
}
jsScroll(document.getElementById('user_list_bar'),6, 'divScrollBar');
}
});
$(".showMorehandle").click(function(){
$.ajax({
type: "POST",
url: "/hhh.php",
dataType: "json",
data:"123",
success: function(data) {
var json=eval(data);
for(var n=0;n<json.length;n++){
jQuery("#users").append("<li class=\"login-user\" ><i class=\"icon-putong\"><img src=\""+json
.perimg+"\" width=\"24px\" height=\"24px\" /></i><span>"+json
.name+"</span><i class=\"groupIcon\"><img src=\""+json
.iconimg+"\"
/></i></li>");
}
jsScroll(document.getElementById('user_list_bar'),6, 'divScrollBar');
}
});
});
});
</script>
</body>
</html>
<?php
$arr = array(
array ('perimg' => 'images/01.png','name' => '游客_342333','iconimg' => 'images/用户 - 小-(9).png'),
array ('perimg' => 'images/01.png','name' => '游客_342333','iconimg' => 'images/用户 - 小-(9).png'),
);
$jsonstr = json_encode($arr);
echo $jsonstr;
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery.min.js"></script>
<script src="jsScroll.js"></script>
<style type="text/css">
*{margin:0;padding:0;}
ul li{list-style:none;}
.showMoreNChildren{width:195px;margin:0 auto;overflow:hidden;padding-right:10px;}
.showMoreNChildren li {width:100%;position: relative;padding: 8px 0 8px;display:block;}
.icon-putong {width: 34px;height: 34px;background: 0;display:inline-block;}
.showMoreNChildren li span {width: 120px;margin: 0 0 0 10px;display:inline-block;font-size: 13px;cursor: default;padding-top: 1px;}
.groupIcon {background: 0;position: absolute;left: 163px;}
.groupIcon img {max-height: 30px;max-width: 30px;}
.divScrollBar{background-color:#ddd;position:absolute;opacity:0.5; filter:Alpha(opacity=50);}
.divScrollBar:hover{opacity:1; filter:Alpha(opacity=100);}
.divScrollBar div{background-color:#aaa; position:absolute; left:0px; top:0px;}
.divScrollBar{background-color:#ddd;position:absolute;opacity:0.5; filter:Alpha(opacity=50);}
.divScrollBar:hover{opacity:1; filter:Alpha(opacity=100);}
.divScrollBar div{background-color:#aaa; position:absolute; left:0px; top:0px;}
.showMorehandle{text-align:center;font-size:14px;color:#09F;}
</style>
</head>
<body>
<div id="user_list_bar" style="width:204px;margin:0 auto;overflow-y:scroll;height:800px;">
<ul id="users" class="showMoreNChildren" pagesize="2">
</ul>
<div class="showMorehandle">更多..</div>
</div>
<script>
$(function(){
$.ajax({
type: "POST",
url: "/hhh.php",
dataType: "json",
data:"123",
success: function(data) {
var json=eval(data);
for(var n=0;n<json.length;n++){
jQuery("#users").append("<li class=\"login-user\" ><i class=\"icon-putong\"><img src=\""+json
.perimg+"\" width=\"24px\" height=\"24px\" /></i><span>"+json
.name+"</span><i class=\"groupIcon\"><img src=\""+json
.iconimg+"\"
/></i></li>");
}
jsScroll(document.getElementById('user_list_bar'),6, 'divScrollBar');
}
});
$(".showMorehandle").click(function(){
$.ajax({
type: "POST",
url: "/hhh.php",
dataType: "json",
data:"123",
success: function(data) {
var json=eval(data);
for(var n=0;n<json.length;n++){
jQuery("#users").append("<li class=\"login-user\" ><i class=\"icon-putong\"><img src=\""+json
.perimg+"\" width=\"24px\" height=\"24px\" /></i><span>"+json
.name+"</span><i class=\"groupIcon\"><img src=\""+json
.iconimg+"\"
/></i></li>");
}
jsScroll(document.getElementById('user_list_bar'),6, 'divScrollBar');
}
});
});
});
</script>
</body>
</html>
<?php
$arr = array(
array ('perimg' => 'images/01.png','name' => '游客_342333','iconimg' => 'images/用户 - 小-(9).png'),
array ('perimg' => 'images/01.png','name' => '游客_342333','iconimg' => 'images/用户 - 小-(9).png'),
);
$jsonstr = json_encode($arr);
echo $jsonstr;
?>
相关文章推荐
- ExtJS3 - 如何实现多表头Grid
- Ext.js表单—Vbox布局(46)
- js 格式化日期
- QRCode.js:使用 JavaScript 生成二维码
- @ResponseBody把结果转换为Json
- Angular JS 文件上传按钮覆盖问题
- javascript通过class获取元素
- EXTJS 4.2 实现 gridpanel 鼠标悬停单元格以提示信息的方式显示单元格内容。
- Ext.js5表单,表格—(等级,评级)小部件(45)
- echarts学习总结(一):jsp整体框架
- js三种读取值的格式
- FastJson简单使用
- Javascript实现Array和String互转换的方法
- JS 关于 == 、===
- JS控制footer在浏览器的底端或者在文档的底端
- javascript 切换动画
- js/jq获取select选中的值
- jstack和线程dump分析
- 常用的验证规则js
- 深入JSX