洛阳中航光电项目,为12年项目,此处使用反编译工具恢复源码,恢复为.netframe4.0版本,但仍需使用ie8访问; 数据库使用oracle,现再192.168.8.3服务器,访问账户scott,密码800100

Ajax.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. *Ajax简易框架
  3. */
  4. function Ajax(url,callback,method)
  5. {
  6. this.url=url;
  7. this.callback=callback;
  8. this.method=method==null?"GET":method;
  9. this.xmlhttp=this.GetXMLHttpRequest();
  10. }
  11. /**
  12. *生成成成xmlhttpRequest对象
  13. */
  14. Ajax.prototype.GetXMLHttpRequest=function (){
  15. var xmlhttp=false;
  16. if(window.ActiveXObject){//IE浏览器
  17. try{
  18. xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  19. }catch(e){
  20. try{
  21. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  22. }catch(e){
  23. xmlhttp=false;
  24. }
  25. }
  26. }else if(window.XMLHttpRequest){//支持支持支持Mozilla、FireFox、Opera等浏览器
  27. try{
  28. xmlhttp=new XMLHttpRequest();
  29. }catch(e){
  30. xmlhttp=false;
  31. }
  32. }
  33. if(!xmlhttp){
  34. alert("无法创建XMLHttpRequest对象");
  35. }
  36. return xmlhttp;
  37. }
  38. /**
  39. *创建请求并发送
  40. */
  41. Ajax.prototype.send=function (){
  42. if(this.xmlhttp){
  43. oThis=this;
  44. this.xmlhttp.open(this.method,this.url,true);
  45. this.xmlhttp.onreadystatechange=function(){
  46. oThis.processResult();
  47. };
  48. this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');//如果method是post时
  49. this.xmlhttp.send(null);
  50. }
  51. }
  52. /**
  53. *接收请求数据
  54. */
  55. Ajax.prototype.processResult=function (){
  56. var athis=this;
  57. if(this.xmlhttp.readystate==null){
  58. this.xmlhttp.addEventListener("load",function(){
  59. athis.result();
  60. },false);
  61. this.xmlhttp.readystate=1;
  62. }
  63. if(this.xmlhttp.readystate==4){
  64. this.result();
  65. }
  66. }
  67. /**
  68. *得到结果
  69. */
  70. Ajax.prototype.result=function(){
  71. if(this.xmlhttp.status==200&&this.xmlhttp.statusText=="OK"){
  72. this.callback(this.xmlhttp);
  73. }else {
  74. alert("数据请求失败");
  75. }
  76. }