fix customer browse in the presense of non-numeric agent_custid, RT#31388
[freeside.git] / fs_selfservice / FS-SelfService / cgi / send_xmlhttp.html
1 <SCRIPT>
2 function rs_init_object () {
3   var A;
4   try {
5     A=new ActiveXObject("Msxml2.XMLHTTP");
6   } catch (e) {
7     try {
8       A=new ActiveXObject("Microsoft.XMLHTTP");
9     } catch (oc) {
10       A=null;
11     }
12   }
13   if(!A && typeof XMLHttpRequest != "undefined")
14     A = new XMLHttpRequest();
15   if (!A)
16     alert("Can't create XMLHttpRequest object");
17   return A;
18 }
19
20 function send_xmlhttp (url,args,callback) {
21   args = args || [];
22   callback = callback || function (data) { return data };
23   var content = '';
24   for (var i = 0; i < args.length; i = i + 2) {
25     content = content + "&" + args[i] + "=" + escape(args[i+1]);
26   }
27   content = content.replace( /[+]/g, '%2B'); // fix unescaped plus signs 
28
29   var xmlhttp = rs_init_object();
30   xmlhttp.open("POST", url, true);
31
32   xmlhttp.onreadystatechange = function() {
33     if (xmlhttp.readyState != 4) 
34       return;
35     if (xmlhttp.status == 200) {
36       var data = xmlhttp.responseText;
37       callback(data);
38     }
39   };
40
41   xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
42   xmlhttp.send(content);
43 }
44 </SCRIPT>
45