-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathejemplo8.html
85 lines (76 loc) · 1.72 KB
/
ejemplo8.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
79
80
81
82
83
84
85
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Ejemplo: dojo/request</title>
<style media="screen">
pre {
height:25em;
width:450px;
overflow:auto;
}
label {
font-weight:bolder;
display:block;
}
#resultDiv {
margin:15px 0;
padding:5px;
width:25em;
}
.error {
color:#DF0101;
font-weight:bolder;
}
.success {
color:#186421;
}
.ready {
color:#062093;
}
.hint {
font-weight:bolder;
background-color:#ff0;
}
dt {
font-weight:bolder;
}
.json {
overflow:scroll;
}
</style>
</head>
<body>
<h1>Ejemplo: dojo/request</h1>
<p>Haz clic para comprobar cómo trabaja dojo/request/xhr.</p>
<div>
<button id="textButton">Recupera el texto</button>
</div>
<br /><br />
<div id="resultDiv">
</div>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js" data-dojo-config="isDebug: 1, async: 1, parseOnLoad: 1"></script>
<script>
require(["dojo/dom", "dojo/on", "dojo/request", "dojo/domReady!"],
function(dom, on, request){
// Results will be displayed in resultDiv
var resultDiv = dom.byId("resultDiv");
// Attach the onclick event handler to the textButton
on(dom.byId('textButton'), "click", function(evt){
// Request the text file
request.get("/Seminario_Dojo/dojo/request/example_text.txt").then(
function(response){
// Display the text file content
resultDiv.innerHTML = "<pre>" + response + "</pre>";
},
function(error){
// Display the error returned
resultDiv.innerHTML = "<div class=\"error\">" + error + "<div>";
}
);
});
}
);
</script>
</body>
</html>