-
Notifications
You must be signed in to change notification settings - Fork 1
/
div_load.html
78 lines (75 loc) · 1.6 KB
/
div_load.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="../lib/jquery-2.min.js"></script>
<style type="text/css">
div.container{
margin:10px;
width:1000px;
height:800px;
border:2px solid blue;
overflow:scroll;
float:left;
}
div.ctrlPanel{
background:#ccc;
float:left;
margin:10px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#selectForm1").click(function(){
//$(".container").load("form1.html");
$(".container").empty();
$.ajax({
type:"GET",
dataType:"application/html",
url:"form1.html",
complete:function(xhr,ts){
switch(xhr.status){
case 0:
break;
case 200:
var responseText = $(xhr.responseText);
$(".container").append($(responseText));
//console.log(xhr);
break;
case 404:
alert("404 NOT FOUND");
break;
default:
alert(xhr.status);
break;
}
}
});
});
$("#selectForm2").click(function(){
$(".container").load("form2.html");
});
$("#submit").click(function(){
var $name1 = $("#name1");
var $hobby1 = $("#hobby1");
if($name1){
console.log($name1.length);
}
if($hobby1){
console.log($hobby1.length);
}
});
});
</script>
</head>
<body>
<div class="container">
</div>
<div class="ctrlPanel">
<button type="button" id="selectForm1">个人信息</button>
<button type="button" id="selectForm2">兴趣爱好</button>
<button type="submit" id="submit">提交</button>
</div>
</body>
</html>