-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.html
56 lines (56 loc) · 1.29 KB
/
ajax.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ajax Exercise</title>
</head>
<body>
<div id="myDiv"></div>
<button>点击更改</button>
</body>
<script src="js/jquery-1.10.2.min.js"></script>
<script>
// $(function(){
// $("button").click(function(){
// var xmlhttp;
// if(window.XMLHttpRequest){
// xmlhttp=new XMLHttpRequest();
// }else{
// xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
// }
// xmlhttp.onreadystatechange=function(){
// if(xmlhttp.readyState==4 && xmlhttp.status==200){
// $("#myDiv").html(xmlhttp.responseText);
// // $("#myDiv").html('1111111111111111');
// }
// };
// xmlhttp.open("GET","music.txt",true);
// xmlhttp.send();
// });
// });
// $(function(){
// $('button').click(function(){
// $.ajax({
// type:"GET",
// url:"music.txt",
// dataType:"json",
// success:function(data){
// var music="<ul>";
// $.each(data,function(i, n){
// music+="<li>"+n["optionValue"]+"</li>";
// });
// music+="</ul>";
// $('#myDiv').append(music);
// }
// });
// return false;
// });
// });
$(function(){
$("button").click(function(){
htmlobj=$.ajax({url:"music.txt",async:false});
$("#myDiv").html(htmlobj.responseText);
});
});
</script>
</html>