1 <SCRIPT TYPE="text/javascript">
3 function rs_init_object() {
6 A=new ActiveXObject("Msxml2.XMLHTTP");
9 A=new ActiveXObject("Microsoft.XMLHTTP");
14 if(!A && typeof XMLHttpRequest != "undefined")
15 A = new XMLHttpRequest();
17 alert("Can't create XMLHttpRequest object");
21 % foreach my $func ( @{$opt{'subs'}} ) {
24 % $furl =~ s/\"/\\\\\"/; #javascript escape
29 function <%$key%><%$func%>() {
30 // count args; build URL
31 var url = "<%$furl%>";
32 var a = <%$key%><%$func%>.arguments;
36 var content = 'sub=<% uri_escape($func) %>';
37 if ( a && typeof a == 'object' && a[0].constructor == Array ) {
42 len = args.length - 1;
44 for (var i = 0; i < len; i++)
45 content = content + "&arg=" + escape(args[i]);
46 content = content.replace( /[+]/g, '%2B'); // fix unescaped plus signs
48 if ( '<%$method%>' == 'GET' ) {
52 //alert('<%$method%> ' + url);
54 var xmlhttp = rs_init_object();
55 xmlhttp.open("<%$method%>", url, true);
57 xmlhttp.onreadystatechange = function() {
58 if (xmlhttp.readyState != 4)
61 if (xmlhttp.status != 200) {
62 alert(xmlhttp.status + " status connecting to " + url);
64 var data = xmlhttp.responseText;
65 //alert('received response: ' + data);
67 if ( data.indexOf("<b>System error</b>") > -1 ) {
69 if ( w = window.open("about:blank") ) {
70 w.document.write(data);
72 // popup blocking? should use an overlib popup instead
73 alert("Error popup disabled; try disabling popup blocking to see");
79 if ( '<%$method%>' == 'POST' ) {
81 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
82 xmlhttp.send(content);
86 xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
91 //rs_debug("x_$func_name url = " + url);
92 //rs_debug("x_$func_name waiting..");
101 my $url = $opt{'url'};
102 my $method = exists($opt{'method'}) ? $opt{'method'} : 'GET';
103 #my @subs = @{ $opt{'subs'};
104 my $key = exists($opt{'key'}) ? $opt{'key'} : '';
106 $url .= ( ($url =~ /\?/) ? '&' : '?' )