ajax向后台传参!!
1 <script type="text/javascript">
2 function Myupdate(btn)
3 {
4 var btnId=btn.id; //获取button的ID
5 var Ubtn=document.getElementById(btnId); //获取button对象
6 var tablerow=Ubtn.parentNode.parentNode; //取得button所在的行对象
7 var fChild=tablerow.getElementsByTagName("td")[0]; //找到对应行的TD对象
8
9 var strHtml="<input type='text' id='kao'>"
10 fChild.innerHTML=strHtml;
11 fChild.focus();
12
13 }
14
15 function Mydelete(btn)
16 {
17 //总行数
18 var tNum=document.all('table1').rows.length;
19 //行数
20 var rowNum=btn.id;
21
22 //时间
23 var now= new Date();
24 var year=now.getYear();
25 var month=now.getMonth()+1;
26 var day=now.getDate();
27 var hour=now.getHours();
28 var minute=now.getMinutes();
29 var second=now.getSeconds();
30 var datetime=year+"-"+month+"-"+day+" "+hour+":"+":"+minute+":"+second;
31
32 var xhr;
33 if (window.XMLHttpRequest) {
34 xhr = new XMLHttpRequest();
35 }
36 else if (window.ActiveXObject) {
37 xhr = new ActiveXObject("Msxml2.XMLHTTP");
38 }
39 else {
40 throw new Error("error,fuck");
41 }
42
43 var url="Default.aspx?rowNum="+rowNum+"&dateTime="+datetime;
44 xhr.open("get",url,true);
45 //xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
46 xhr.send(null);
47 xhr.onreadystatechange= function()
48 {
49 if (xhr.readyState == 4||xhr.readyState=='complate')
50 {
51 if (xhr.status >= 200 && xhr.status < 300)
52 {
53 var theText=xhr.responseText;
54 alert(theText);
55 }
56 }
57 }
58 }
59
posted on 2009-04-19 22:12 YWN's blog 阅读(208) 评论(0) 收藏 举报
浙公网安备 33010602011771号