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 =~ /\?/) ? '&' : '?' )
14 <SCRIPT TYPE="text/javascript">
16 function rs_init_object() {
19 A=new ActiveXObject("Msxml2.XMLHTTP");
22 A=new ActiveXObject("Microsoft.XMLHTTP");
27 if(!A && typeof XMLHttpRequest != "undefined")
28 A = new XMLHttpRequest();
30 alert("Can't create XMLHttpRequest object");
35 <% foreach my $func ( @{$opt{'subs'}} ) {
38 $furl =~ s/\"/\\\\\"/; #javascript escape
42 function <%=$key%><%=$func%>() {
43 // count args; build URL
44 var url = "<%=$furl%>";
45 var a = <%=$key%><%=$func%>.arguments;
49 var content = 'sub=<%= uri_escape($func) %>';
50 if ( a && typeof a == 'object' && a[0].constructor == Array ) {
55 len = args.length - 1;
57 for (var i = 0; i < len; i++)
58 content = content + "&arg=" + escape(args[i]);
59 content = content.replace( /[+]/g, '%2B'); // fix unescaped plus signs
61 if ( '<%=$method%>' == 'GET' ) {
65 //alert('<%=$method%> ' + url);
67 var xmlhttp = rs_init_object();
68 xmlhttp.open("<%=$method%>", url, true);
70 xmlhttp.onreadystatechange = function() {
71 if (xmlhttp.readyState != 4)
74 if (xmlhttp.status != 200) {
75 alert(xmlhttp.status + " status connecting to " + url);
77 var data = xmlhttp.responseText;
78 //alert('received response: ' + data);
80 if ( data.indexOf("<b>System error</b>") > -1 ) {
82 if ( w = window.open("about:blank") ) {
83 w.document.write(data);
85 // popup blocking? should use an overlib popup instead
86 alert("Error popup disabled; try disabling popup blocking to see");
92 if ( '<%=$method%>' == 'POST' ) {
94 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
95 xmlhttp.send(content);
99 xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
104 //rs_debug("x_$func_name url = " + url);
105 //rs_debug("x_$func_name waiting..");