ajax.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. var http_request = false;
  2. function makeRequest(url, functionName, httpType, sendData) {
  3. http_request = false;
  4. if (!httpType) httpType = "GET";
  5. if (window.XMLHttpRequest) { // Non-IE...
  6. http_request = new XMLHttpRequest();
  7. if (http_request.overrideMimeType) {
  8. http_request.overrideMimeType('text/plain');
  9. }
  10. } else if (window.ActiveXObject) { // IE
  11. try {
  12. http_request = new ActiveXObject("Msxml2.XMLHTTP");
  13. } catch (e) {
  14. try {
  15. http_request = new ActiveXObject("Microsoft.XMLHTTP");
  16. } catch (e) {}
  17. }
  18. }
  19. if (!http_request) {
  20. alert('Cannot send an XMLHTTP request');
  21. return false;
  22. }
  23. var changefunc="http_request.onreadystatechange = "+functionName;
  24. eval (changefunc);
  25. //http_request.onreadystatechange = alertContents;
  26. http_request.open(httpType, url, true);
  27. http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  28. http_request.send(sendData);
  29. }
  30. function getReturnedText () {
  31. if (http_request.readyState == 4) {
  32. if (http_request.status == 200) {
  33. var messagereturn = http_request.responseText;
  34. return messagereturn;
  35. } else {
  36. alert('There was a problem with the request.');
  37. }
  38. }
  39. }
  40. function EchoReturnedText() {
  41. if (http_request.readyState == 4) {
  42. if (http_request.status == 200) {
  43. var messagereturn = http_request.responseText;
  44. if(messagereturn!='isfail')
  45. {
  46. var r;
  47. r=messagereturn.split('|');
  48. if(r.length!=1)
  49. {
  50. if(r[0]!='')
  51. {
  52. document.getElementById(r[1]).innerHTML=r[0];
  53. }
  54. if(r[2]!='')
  55. {
  56. alert(r[2]);
  57. }
  58. }
  59. else
  60. {
  61. document.getElementById('ajaxarea').innerHTML=messagereturn;
  62. }
  63. }
  64. } else {
  65. alert('There was a problem with the request.');
  66. }
  67. }
  68. }
  69. function EchoReturnedReTitle() {
  70. if (http_request.readyState == 4) {
  71. if (http_request.status == 200) {
  72. var messagereturn = http_request.responseText;
  73. if(messagereturn!='isfail')
  74. {
  75. if(messagereturn=='1')
  76. {
  77. document.getElementById('eajaxretitle').innerHTML='<font color="red"标题已存在</font>';
  78. }
  79. else
  80. {
  81. }
  82. }
  83. } else {
  84. alert('There was a problem with the request.');
  85. }
  86. }
  87. }
  88. function edohshowkey(showid,vname,baseurl){
  89. document.getElementById(showid).innerHTML='<img src="'+baseurl+'ShowKey.php?v='+vname+'&t='+Math.random()+'" name="'+vname+'KeyImg" id="'+vname+'KeyImg" align="bottom" onclick=edohshowkey("'+showid+'","'+vname+'","'+baseurl+'") title="看不清楚,点击刷新">';
  90. }
  91. function edozoomimg(o){
  92. var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
  93. return false;
  94. }
  95. function edoautosimg(o){
  96. if(o.width>screen.width*0.5)
  97. {
  98. o.width=screen.width*0.5;
  99. }
  100. }