-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
107 lines (89 loc) · 3.24 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome</title>
<script type="text/javascript" src = "xmlhttprequest.js"></script>
<script type="text/javascript">
function $(id) {
return document.getElementById(id);
}
window.onload = function () {
$("upload_btn").onclick = function () {
var id = $("note_id").value;
var title = $("note_title").value;
var content = $("note_content").value;
var stick = $("note_stick").value;
var lock = $("note_lock").value;
var datetime = new Date().getTime();
var upload_uid = $("upload_uid").value;
var url = './upload.php';
//var postStr = "note_id="+id+'¬e_title='+title+'¬e_content='+content+'¬e_stick='+stick+'¬e_lock='+lock+'&datetime='+new Date().getTime();
var postStr = 'notes=[';
postStr += '{"id":' + id + ',"title":' + '"' + title + '"' + ',"content":' + '"' + content + '"' + ',"stick":' + stick + ',"lock":' + lock + ',"datetime":' + datetime +'}';
for (var i = 0; i < 10; i++) {
postStr += ',{"id":' + '"' + id + '"' + ',"title":' + '"' + title + '"' + ',"content":' + '"' + content + '"' + ',"stick":' + stick + ',"lock":' + lock + ',"datetime":' + datetime +'}';
}
postStr += ']&uid=' + upload_uid;
alert(postStr);
xmlhttp.open('post',url,true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
var msg = xmlhttp.responseText;
if (msg == '') {
alert("失败");
}else{
alert(msg + "行受影响");
}
}
}
}
//发送请求
xmlhttp.send(postStr);
};
$("download_btn").onclick = function () {
var download_uid = $("download_uid").value;
url = './download.php?uid=' + download_uid;
xmlhttp.open('get',url,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
var json = eval('(' + xmlhttp.responseText +')');
var textarea = $("textarea1");
var value = '';
for (var i = 0; i < json.length; i++) {
var note = json[i];
for (var e in note) {
value += e + "=" + note[e] + ",";
}
value += "\n";
}
textarea.value = value;
}
}
}
//发送请求
xmlhttp.send(null);
};
};
</script>
</head>
<body>
<h3>Upload</h3>
<hr/>
<span>id:</span><input value = "100" type = "text" id = "note_id" /><br/>
<span>title:</span><input value = "vvvvvvvvvvvvv" type = "text" id = "note_title" /><br/>
<span>content:</span><input value = "jjjjjjjjjj" type = "text" id = "note_content" /><br/>
<span>stick:</span><input value = "1" type = "text" id = "note_stick" /><br/>
<span>lock:</span><input value = "0" type = "text" id = "note_lock" /><br/>
<span>uid:</span><input value = "1" type = "text" id = "upload_uid" /><br/>
<input type = "button" value = "upload" id = "upload_btn" />
<h3>downLoad</h3>
<hr/>
<span>uid:</span><input value = "1" type = "text" id = "download_uid" /><br/>
<input type = "button" value = "download" id = "download_btn" /><br/><br/>
<textarea rows="100" cols="100" id = "textarea1"></textarea>
</body>
</html>