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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Testing dojo.io.script</title>
<style type="text/css">
@import "../../resources/dojo.css";
</style>
<script type="text/javascript"
src="../../dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
dojo.require("doh.runner");
dojo.require("dojo.io.script");
dojo.addOnLoad(function(){
doh.register("t",
[
function ioScriptSimple(t){
var d = new doh.Deferred();
var td = dojo.io.script.get({
url: "scriptSimple.js",
checkString: "myTasks"
});
td.addBoth(function(res){
if(typeof(myTasks) != "undefined"
&& t.is("Do dishes.", myTasks[1])){
d.callback(true);
}else{
d.errback(false);
}
});
return d;
},
function ioScriptJsonp(t){
var d = new doh.Deferred();
var td = dojo.io.script.get({
url: "scriptJsonp.js",
content: { foo: "bar" },
callbackParamName: "callback"
});
td.addBoth(function(res){
if(!(res instanceof Error) &&
t.is("mammal", res.animalType)){
d.callback(true);
}else{
d.errback(false);
}
});
return d;
},
function ioScriptJsonpTimeout(t){
var d = new doh.Deferred();
var td = dojo.io.script.get({
url: "../_base/timeout.php",
callbackParamName: "callback",
content: {Foo: 'Bar'},
timeout: 500,
handleAs: "json",
preventCache: true,
handle: function(response, ioArgs){
if(response instanceof Error && response.dojoType == "timeout"){
console.debug("FOO OK TEST");
d.callback(true);
}else{
console.debug("FOO FAIL TEST");
d.errback(false);
}
}
});
return d;
}
]
);
doh.run();
});
/*
dojo.addOnLoad(function(){
td = dojo.io.script.get({
url: "scriptSimple.js",
checkString: "myTasks"
});
td.addCallback(function(res){
alert(myTasks);
alert(myTasks[1]);
if(typeof(myTasks) != "undefined"
&& "Do dishes." == myTasks[1]){
alert("yeah");
}else{
alert("boo");
}
});
});
*/
</script>
</head>
<body>
</body>
</html>
|