4 % my $url = $opt{'url'};
5 % my $method = exists($opt{'method'}) ? $opt{'method'} : 'GET';
6 % #my @subs = @{ $opt{'subs'};
7 % my $key = exists($opt{'key'}) ? $opt{'key'} : '';
9 % $url .= ( ($url =~ /\?/) ? '&' : '?' )
10 % if $method eq 'GET';
15 <SCRIPT TYPE="text/javascript">
17 function rs_init_object() {
20 A=new ActiveXObject("Msxml2.XMLHTTP");
23 A=new ActiveXObject("Microsoft.XMLHTTP");
28 if(!A && typeof XMLHttpRequest != "undefined")
29 A = new XMLHttpRequest();
31 alert("Can't create XMLHttpRequest object");
35 % foreach my $func ( @{$opt{'subs'}} ) {
38 % $furl =~ s/\"/\\\\\"/; #javascript escape
43 function <%$key%><%$func%>() {
44 // count args; build URL
45 var url = "<%$furl%>";
46 var a = <%$key%><%$func%>.arguments;
50 var content = 'sub=<% uri_escape($func) %>';
51 if ( a && typeof a == 'object' && a[0].constructor == Array ) {
56 len = args.length - 1;
58 for (var i = 0; i < len; i++)
59 content = content + "&arg=" + escape(args[i]);
60 content = content.replace( /[+]/g, '%2B'); // fix unescaped plus signs
62 if ( '<%$method%>' == 'GET' ) {
66 //alert('<%$method%> ' + url);
68 var xmlhttp = rs_init_object();
69 xmlhttp.open("<%$method%>", url, true);
71 xmlhttp.onreadystatechange = function() {
72 if (xmlhttp.readyState != 4)
75 if (xmlhttp.status != 200) {
76 alert(xmlhttp.status + " status connecting to " + url);
78 var data = xmlhttp.responseText;
79 //alert('received response: ' + data);
81 if ( data.indexOf("<b>System error</b>") > -1 ) {
83 if ( w = window.open("about:blank") ) {
84 w.document.write(data);
86 // popup blocking? should use an overlib popup instead
87 alert("Error popup disabled; try disabling popup blocking to see");
93 if ( '<%$method%>' == 'POST' ) {
95 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
96 xmlhttp.send(content);
100 xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
105 //rs_debug("x_$func_name url = " + url);
106 //rs_debug("x_$func_name waiting..");