5 my $method = exists($opt{'method'}) ? $opt{'method'} : 'GET';
6 #my @subs = @{ $opt{'subs'};
8 $url .= ( ($url =~ /\?/) ? '&' : '?' )
13 <SCRIPT TYPE="text/javascript">
15 function rs_init_object() {
18 A=new ActiveXObject("Msxml2.XMLHTTP");
21 A=new ActiveXObject("Microsoft.XMLHTTP");
26 if(!A && typeof XMLHttpRequest != "undefined")
27 A = new XMLHttpRequest();
29 alert("Can't create XMLHttpRequest object");
34 <% foreach my $func ( @{$opt{'subs'}} ) {
37 $furl =~ s/\"/\\\\\"/; #javascript escape
41 function <%=$func%>() {
42 // count args; build URL
43 var url = "<%=$furl%>";
44 var a = <%=$func%>.arguments;
48 var content = 'sub=<%= uri_escape($func) %>';
49 if ( a && typeof a == 'object' && a[0].constructor == Array ) {
54 len = args.length - 1;
56 for (var i = 0; i < len; i++)
57 content = content + "&arg=" + escape(args[i]);
58 content = content.replace( /[+]/g, '%2B'); // fix unescaped plus signs
60 if ( '<%=$method%>' == 'GET' ) {
64 //alert('<%=$method%> ' + url);
66 var xmlhttp = rs_init_object();
67 xmlhttp.open("<%=$method%>", url, true);
69 xmlhttp.onreadystatechange = function() {
70 if (xmlhttp.readyState != 4)
73 if (xmlhttp.status != 200) {
74 alert(xmlhttp.status + " status connecting to " + url);
76 var data = xmlhttp.responseText;
77 //alert('received response: ' + data);
79 if ( data.indexOf("<b>System error</b>") > -1 ) {
81 if ( w = window.open("about:blank") ) {
82 w.document.write(data);
84 // popup blocking? should use an overlib popup instead
85 alert("Error popup disabled; try disabling popup blocking to see");
91 if ( '<%=$method%>' == 'POST' ) {
93 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
94 xmlhttp.send(content);
98 xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
103 //rs_debug("x_$func_name url = " + url);
104 //rs_debug("x_$func_name waiting..");