- 积分
- 40165
- 好友
- 记录
- 主题
- 帖子
- 听众
- 收听
|
我同事一起能的个小例子大家看看吧
有好的建议给提提
[code=html]<!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>
<title></title>
<script src="js/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script>
/*
Jsion格式如下
ShowDiv([
{"Guid":"81c43947-fdd8-4c6d-859b-00182e0fe4ed","ParentGuid":"d7b816cb-b021-48a3-b374-22e483a569fa","Period":8,"TimeUnit":0,"Cost":960.0000,"FirstBuy":960.0000,"Renew":960.0000},
{"Guid":"6328fabe-0572-47d9-bbaf-00754e266480","ParentGuid":"d6c3854e-eafe-4af1-b527-00d37470771e","Period":7,"TimeUnit":0,"Cost":840.0000,"FirstBuy":840.0000,"Renew":840.0000},
{"Guid":"cc05275f-b1cd-4766-9433-00a161c0eb8d","ParentGuid":"6d45b3f4-fea0-4454-8fad-370805b60e99","Period":5,"TimeUnit":0,"Cost":39995.0000,"FirstBuy":39995.0000,"Renew":39995.0000}
])
*/
$(document).ready(function () {
$("#Button1").click(function () {
FillUrls();
});
});
//加载列表
function FillUrls() {
$.ajax({
async: false,
url: "JsonTest.ashx",
type: "GET",
dataType: 'jsonp',
timeout: 5000,
success: function (json) {
}
});
}
function ShowDiv(strurls) {
var $ul = $("<ul></ul>");
$.each(strurls, function (i, v) {
$("<li/>").text(v["Guid"] + " " + v["Cost"]).appendTo($ul)
});
//循环方式
$("body").append($ul);
//单独取
$("body").append(strurls[0]["Guid"]);
}
</script>
</head>
<body>
<input id="Button1" type="button" value="button" />
</body>
</html>
[/code]
|
|