-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
30 lines (30 loc) · 1.19 KB
/
test.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>上传</title>
<script type="text/javascript" src="script/jquery-3.1.1.min.js"></script>
</head>
<body>
<form id="form1" action="http://47.75.95.33/websrc/web/webupload/type.htm" target="frame1" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="text" name="type" value="cz">
<input type="button" value="上传" onclick="upload()">
</form>
<iframe name="frame1" frameborder="0" height="40"></iframe>
<!-- 其实我们可以把iframe标签隐藏掉 -->
<script type="text/javascript">
function upload() {
$("#form1").submit();
var t = setInterval(function() {
//获取iframe标签里body元素里的文字。即服务器响应过来的"上传成功"或"上传失败"
var word = $("iframe[name='frame1']").contents().find("body").text();
if (word != "") {
alert(word); //弹窗提示是否上传成功
clearInterval(t); //清除定时器
}
}, 1000);
}
</script>
</body>
</html>