ajax.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 edoshowkey(showid,vname,baseurl){
  70. document.getElementById(showid).innerHTML='<img src="'+baseurl+'e/ShowKey/?v='+vname+'&t='+Math.random()+'" name="'+vname+'KeyImg" id="'+vname+'KeyImg" align="bottom" onclick=edoshowkey("'+showid+'","'+vname+'","'+baseurl+'") title="看不清楚,点击刷新">';
  71. }
  72. function edozoomimg(o){
  73. var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
  74. return false;
  75. }
  76. function edoautosimg(o){
  77. if(o.width>screen.width*0.5)
  78. {
  79. o.width=screen.width*0.5;
  80. }
  81. }