]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojo/tests/io/script.html
Comment class stub
[eow] / static / dojo-release-1.1.1 / dojo / tests / io / script.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2         "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4         <head>
5                 <title>Testing dojo.io.script</title>
6                 <style type="text/css">
7                         @import "../../resources/dojo.css";
8                 </style>
9                 <script type="text/javascript" 
10                         src="../../dojo.js" djConfig="isDebug: true"></script>
11                 <script type="text/javascript">
12                         dojo.require("doh.runner");
13                         dojo.require("dojo.io.script");
14
15                         dojo.addOnLoad(function(){
16                                 doh.register("t", 
17                                         [
18                                                 function ioScriptSimple(t){
19                                                         var d = new doh.Deferred();
20                                                         var td = dojo.io.script.get({
21                                                                 url: "scriptSimple.js",
22                                                                 checkString: "myTasks"
23                                                         });
24                                                         td.addBoth(function(res){
25                                                                 if(typeof(myTasks) != "undefined"
26                                                                         && t.is("Do dishes.", myTasks[1])){
27                                                                         d.callback(true);
28                                                                 }else{
29                                                                         d.errback(false);
30                                                                 }
31                                                         });
32                                                         return d;
33                                                 },
34                                                 function ioScriptJsonp(t){
35                                                         var d = new doh.Deferred();
36                                                         var td = dojo.io.script.get({
37                                                                 url: "scriptJsonp.js",
38                                                                 content: { foo: "bar" },
39                                                                 callbackParamName: "callback"
40                                                         });
41                                                         td.addBoth(function(res){
42                                                                 if(!(res instanceof Error) && 
43                                                                         t.is("mammal", res.animalType)){
44                                                                         d.callback(true);
45                                                                 }else{
46                                                                         d.errback(false);
47                                                                 }
48                                                         });
49                                                         return d;                                                       
50                                                 },
51                                                 function ioScriptJsonpTimeout(t){
52                                                         var d = new doh.Deferred();
53                                                         var td = dojo.io.script.get({
54                                                                 url: "../_base/timeout.php",
55                                                                 callbackParamName: "callback",
56                                                                 content: {Foo: 'Bar'},
57                                                                 timeout: 500,
58                                                                 handleAs: "json",
59                                                                 preventCache: true,
60                                                                 handle: function(response, ioArgs){
61                                                                         if(response instanceof Error && response.dojoType == "timeout"){
62                                                                                 console.debug("FOO OK TEST");
63                                                                                 d.callback(true);
64                                                                         }else{
65                                                                                 console.debug("FOO FAIL TEST");
66                                                                                 d.errback(false);
67                                                                         }
68                                                                 }
69                                                         });
70                                                         return d;
71                                                 }
72                                         ]
73                                 );
74                                 doh.run();
75                         });
76
77 /*
78                         dojo.addOnLoad(function(){
79                                 td = dojo.io.script.get({
80                                         url: "scriptSimple.js",
81                                         checkString: "myTasks"
82                                 });
83                                 td.addCallback(function(res){
84                                         alert(myTasks);
85                                         alert(myTasks[1]);
86                                         if(typeof(myTasks) != "undefined"
87                                                 && "Do dishes." == myTasks[1]){
88                                                 alert("yeah");
89                                         }else{
90                                                 alert("boo");
91                                         }
92                                 });
93                         });
94 */
95
96                 </script>
97         </head>
98         <body>
99
100         </body>
101 </html>