jqhttpsdk.js 2.4 KB

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