Subversion Repositories cryptochat

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
<cfinclude template="sajax.cfm">
2
<cfscript>
3
        function test_get() {
4
                return test();
5
        }
6
 
7
        function test_post() {
8
                return test();
9
        }
10
 
11
        function test() {
12
                s = "URI: example_options.cfm";
13
                s = "#s#
14
-- GET --
15
";
16
                if(isdefined("URL.rsargs"))
17
                        s = "#s##URL.rsargs#";
18
                s = "#s#
19
 
20
-- POST --
21
";
22
                if(isdefined("FORM.rsargs"))
23
                        s = "#s##FORM.rsargs#";
24
 
25
                return s;
26
        }
27
 
28
        function get_the_time() {
29
                return "#DateFormat(now(),"yyyy-mm-dd ")##TimeFormat(now() ,"HH:mm:ss")#";
30
        }
31
 
32
        function pause(sec) {
33
                thread = CreateObject("java", "java.lang.Thread");
34
                thread.sleep(sec*1000);
35
        }
36
 
37
//      $sajax_debug_mode = true;
38
 
39
        //GET functions
40
        sajax_request_type = "GET";
41
        sajax_export("test_get", "get_the_time", "test", "otherefucntion2");
42
 
43
        //POST functions
44
        sajax_request_type = "POST";
45
        sajax_export("test_post");
46
 
47
        //synchronous GET functions
48
        sajax_request_type = "GET";
49
        sajax_request_asynchronous = "false";
50
        sajax_export("pause");
51
 
52
        //GET functions from a different uri
53
        sajax_request_type = "GET";
54
        sajax_remote_uri = "example_otheruri.cfm";
55
        sajax_export("otherefucntion");
56
 
57
        sajax_handle_client_request();
58
 
59
</cfscript>
60
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
61
<html xmlns="http://www.w3.org/1999/xhtml">
62
<head>
63
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
64
<title>Example of Sajax Options</title>
65
<script type="text/javascript" src="json2.stringify.js"></script>
66
<script type="text/javascript" src="json_stringify.js"></script>
67
<script type="text/javascript" src="json_parse_state.js"></script>
68
<script type="text/javascript" src="sajax.js"></script>
69
<script type="text/javascript"><!--
70
        <cfscript>sajax_show_javascript();</cfscript>
71
        function print_result(v) {
72
                alert(v);
73
        }
74
//-->
75
</script>
76
</head>
77
<body>
78
<!-- Testing if the browser supports GET -->
79
<button onclick="x_test_get(1, 2, 3, print_result);">Test GET</button>
80
 
81
<!-- Testing if the browser supports POST -->
82
<button onclick="x_test_post(1, 2, 3, print_result);">Test POST</button>
83
 
84
<!-- Forcing the function to POST -->
85
<button onclick="sajax_request_type ='POST'; x_test(1, 2, 3, print_result); sajax_request_type ='';">Test force POST</button>
86
 
87
<!-- if sajax_target_id is set, the sesponce will be inserted as HTML in an element with sajax_target_id for id-->
88
<button onclick="sajax_target_id = 'time'; x_get_the_time(); sajax_target_id = '';">Test updating IDs</button>
89
 
90
<!-- Calling a synchronous will cause the script to wait for the responce -->
91
<button onclick="x_pause(3, function(){}); alert('Link was clicked!');">Test synchronous</button>
92
 
93
<!-- Different URI set at config -->
94
<button onclick="x_otherefucntion(print_result);">Call to other uri.</button>
95
 
96
<!-- Forece different URI at runtime -->
97
<button onclick="sajax_remote_uri = 'example_otheruri.cfm'; x_otherefucntion2(print_result); sajax_remote_uri = '';">Force call to other uri.</button>
98
<div id="time"><em>Time will appear here</em></div>
99
</body>
100
</html>