jqhttpsdk.js 2.6 KB

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