<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testeval.aspx.cs" Inherits="testeval" %>
<!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 runat="server">
<title>無標題頁</title>
<script language ="javascript" type="text/javascript" src="jquery-1.3.2.js" ></script>
<script language =Javascript type="text/javascript" >
$(function(){
$("input[type=button]:last").click(
function()
{
$.ajax(
{type:"GET",
http://www.cnblogs.com/sweting/admin/%22Handler2.ashx",
data:"t="+new Date(),
dataType:'text',
ajaxStart:function(){
$("#ab").html("ajax開始…………");
},
ajaxSend:function(){
$("#ab").html("請求已發出……");
},
ajaxSuccess:function(){
$("#ab").html("非同步請求成功");
},
error:function(){
$("#ab").html("請求失敗1");
},
ajaxError:function(){
$("#ab").html("請求失敗2");
},
beforeSend:function(){
$("#ab").html("準備載入資料……");
},
complete:function(){
$("#ab").html("資料載入完成");
},
ajaxComplete:function(){
$("#ab").html("ajax完成!");
},
ajaxStop:function(){
$("#ab").html("ajax停止!");
},
success:function(dat){
//$("#datas").html("");
var da1=eval('('+dat+')');
var tab=da1.tb;
for(var i=0;i<tab.length;i++){
var row = $("#row").clone();
row.find("#riqi").text(tab[i].news_id);
row.find("#haoma").text(tab[i].news_title);
row.find("#news_type").text(tab[i].news_type);
row.find("#news_typeid").text(tab[i].news_typeid);
//row.attr("id","ready");//改變綁定好資料的行的id
row.appendTo("#datas");//添加到模板的容器中
}
}
}
);
});
});
function ab()
{
$.each({ name: "John", lang: "JS" },function(i,n){
alert("Item"+i+":"+n);
if(i==1)
return false;
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" value="eact" onclick ="ab();" />
<div id="ab"></div>
<table id="datas" border="1" cellspacing="0" style="border-collapse: collapse">
<tr>
<th style="width:100px;" align="center">日期</th>
<th style="width:100px;" align="center">號碼</th>
<th >type</th>
<th>typeid</th>
</tr>
<tr id="row" >
<td id="riqi"></td>
<td id="haoma"></td>
<td id="news_type"></td>
<td id="news_typeid"></td>
</tr>
</table>
<input type="button" value="test" />
</div>
</form>
</body>
</html>