testadmin.htm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. var http_request
  5. var adminpadd
  6. function loadXMLDoc(url)
  7. {
  8. http_request=null
  9. // code for Mozilla, etc.
  10. if (window.XMLHttpRequest)
  11. {
  12. http_request=new XMLHttpRequest()
  13. }
  14. // code for IE
  15. else if (window.ActiveXObject)
  16. {
  17. http_request=new ActiveXObject("Microsoft.XMLHTTP")
  18. }
  19. if (http_request!=null)
  20. {
  21. http_request.onreadystatechange=state_Change
  22. http_request.open("GET",url,true)
  23. http_request.send(null)
  24. }
  25. else
  26. {
  27. alert("Your browser does not support XMLHTTP.")
  28. }
  29. }
  30. function state_Change()
  31. {
  32. // if xmlhttp shows "loaded"
  33. if (http_request.readyState==4)
  34. {
  35. // if "OK"
  36. if (http_request.status==200)
  37. {
  38. document.getElementById('T1').innerHTML=http_request.responseText
  39. }
  40. else
  41. {
  42. alert("Problem retrieving data:" + http_request.statusText)
  43. }
  44. }
  45. }
  46. //var http_request = false;
  47. function makePOSTRequest(url, parameters) {
  48. http_request = false;
  49. if (window.XMLHttpRequest) { // Mozilla, Safari,...
  50. http_request = new XMLHttpRequest();
  51. if (http_request.overrideMimeType) {
  52. // set type accordingly to anticipated content type
  53. //http_request.overrideMimeType('text/xml');
  54. http_request.overrideMimeType('text/html');
  55. }
  56. } else if (window.ActiveXObject) { // IE
  57. try {
  58. http_request = new ActiveXObject("Msxml2.XMLHTTP");
  59. } catch (e) {
  60. try {
  61. http_request = new ActiveXObject("Microsoft.XMLHTTP");
  62. } catch (e) {}
  63. }
  64. }
  65. if (!http_request) {
  66. alert('Cannot create XMLHTTP instance');
  67. return false;
  68. }
  69. http_request.onreadystatechange =state_Change
  70. http_request.open('POST', url, true);
  71. http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  72. http_request.setRequestHeader("Content-length", parameters.length);
  73. http_request.setRequestHeader("Connection", "close");
  74. http_request.send(parameters);
  75. }
  76. function alertContents() {
  77. if (http_request.readyState == 4) {
  78. if (http_request.status == 200) {
  79. //alert(http_request.responseText);
  80. result = http_request.responseText;
  81. document.getElementById('T1').innerHTML = result;
  82. } else {
  83. alert('There was a problem with the request.');
  84. }
  85. }
  86. }
  87. function get(obj) {
  88. var poststr = "FirstName=" + encodeURI( document.getElementById("FirstName").value ) +
  89. "&LastName=" + encodeURI( document.getElementById("LastName").value )
  90. + "&PassWord=" + encodeURI( document.getElementById("PassWord").value )
  91. + "&AdminPass=" + adminpass;
  92. makePOSTRequest('Admin/NewAccount', poststr);
  93. }
  94. function setpass(obj)
  95. {
  96. adminpass = encodeURI( document.getElementById("Adminpss").value );
  97. makePOSTRequest('Admin/Login', adminpass);
  98. }
  99. </script>
  100. </head>
  101. <body onload="loadXMLDoc('Admin/Welcome')">
  102. <div id="T1" style="border:1px solid black;height:500;width:800">
  103. <br>
  104. </div><br />
  105. <button onclick="loadXMLDoc('Admin/Clients')">Clients</button>
  106. <button onclick="loadXMLDoc('Admin/Accounts')">Accounts</button>
  107. <button onclick="loadXMLDoc('Admin/Entities')">Entities</button>
  108. </body>
  109. </html>