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