jqhttpsdk.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * 获取数据ajax-get请求
  3. * @author chanjunkai
  4. */
  5. // var http_ip_prot = 'http://192.168.136.40:4696/'
  6. let domain = document.domain;
  7. // let http_ip_prot = 'http://192.168.136.40:7724/';
  8. //生产环境
  9. // let http_ip_prot = 'http://47.107.129.126:7724/';
  10. var http_ip_prot = convertTemp()+ "/";
  11. if( http_ip_prot.indexOf("zositech")==-1){
  12. http_ip_prot="http://192.168.136.39:8000/";
  13. http_ip_prot = 'http://47.107.129.126:7724/';
  14. // http_ip_prot = 'http://127.0.0.1:8000/'
  15. // http_ip_prot = 'http://192.168.136.40:7724/';
  16. // let http_ip_prot = 'http://192.168.136.40:7724/';
  17. console.log(http_ip_prot);
  18. }else{
  19. console.log(http_ip_prot);
  20. }
  21. // http_ip_prot="http://192.168.136.39:8000/";
  22. // 获取访问路径
  23. function convertTemp(){
  24.    var the_url = document.location.toString();
  25.    var first_split = the_url.split("//");
  26.    var without_resource = first_split[1];
  27.    var second_split = without_resource.split("/");
  28.    var domain = second_split[0];
  29. return first_split[0] +'//'+ domain;
  30. }
  31. $.GetJSON = function (url, data, callback) {
  32. $.ajax({
  33. url: url,
  34. type: "get",
  35. contentType: "application/json",
  36. dataType: "json",
  37. timeout: 10000,
  38. data: data,
  39. success: function (data) {
  40. callback(data);
  41. }
  42. });
  43. };
  44. /**
  45. * 提交json数据的post请求
  46. * @author laixm
  47. */
  48. $.postJSON = function (url, data, callback) {
  49. $.ajax({
  50. url: url,
  51. type: "post",
  52. contentType: "application/json",
  53. dataType: "json",
  54. data: data,
  55. timeout: 60000,
  56. success: function (msg) {
  57. callback(msg);
  58. },
  59. error: function (xhr, textstatus, thrown) {
  60. }
  61. });
  62. };
  63. /**
  64. * 修改数据的ajax-put请求
  65. * @author laixm
  66. */
  67. $.putJSON = function (url, data, callback) {
  68. $.ajax({
  69. url: url,
  70. type: "put",
  71. contentType: "application/json",
  72. dataType: "json",
  73. data: data,
  74. timeout: 20000,
  75. success: function (msg) {
  76. callback(msg);
  77. },
  78. error: function (xhr, textstatus, thrown) {
  79. }
  80. });
  81. };
  82. /**
  83. * 删除数据的ajax-delete请求
  84. * @author laixm
  85. */
  86. $.deleteJSON = function (url, data, callback) {
  87. $.ajax({
  88. url: url,
  89. type: "delete",
  90. contentType: "application/json",
  91. dataType: "json",
  92. data: data,
  93. success: function (msg) {
  94. callback(msg);
  95. },
  96. error: function (xhr, textstatus, thrown) {
  97. }
  98. });
  99. };