|
|
<!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="http://imwujianhao.blog.163.com/blog/../jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
function BtnClick() {
var uid = $("#Text1").val();
var pwd = $("#Text2").val();
$.ajax({
url: "json.ashx",
type: "POST",
data: { cmd: "GetInfo", Password: pwd },
beforeSend: loading,
success: function(data) {
var json = eval(data); //eval("(" + data + ")");
$("#dd").empty(); //清除dd的信息
$.each(json, function(idx, item) {
var user = item.UserName;
var pass = item.PWD;
$("#dd").append("<b>用户名:" + user + " 密码:" + pass + "</b>");
});
}
});
}
function loading() {
$("#dd").html("<img src='http://imwujianhao.blog.163.com/blog/20-0.gif' />");
}
function BtnClick1() {
$.ajax({
url: "json.ashx",
type: "POST",
data: { cmd: "GetInfo1" },
beforeSend: loading,
success: function(data) {
//使用eval函数
var json = eval(data);
$("#dd").empty();
//因为上面为list集合
for (var i = 0; i < json.length; i++) {
$("#dd").append("<h3>用户名:" + json[i].UserName + " 密码:" + json[i].PWD + "</h3>");
//alert(json[i].Id + "Name:" + json[i].Name);
}
}
});
}
</script>
</head>
<body>
<div>
<input type="text" name="Text1" id="Text1" /><br />
<input type="text" name="Text2" id="Text2" />
<br />
<input type="button" id="btn1" value="事件1" />
<input type="button" id="Button1" value="事件2" />
</div>
<div id="dd">
sd
</div>
</body>
</html> |
|