jqhttpsdk.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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://www.zositech.xyz:7724/';
  10. $.GetJSON = function (url, data, callback) {
  11. $.ajax({
  12. url: url,
  13. type: "get",
  14. contentType: "application/json",
  15. dataType: "json",
  16. timeout: 10000,
  17. data: data,
  18. success: function (data) {
  19. callback(data);
  20. }
  21. });
  22. };
  23. /**
  24. * 提交json数据的post请求
  25. * @author laixm
  26. */
  27. $.postJSON = function (url, data, callback) {
  28. $.ajax({
  29. url: url,
  30. type: "post",
  31. contentType: "application/json",
  32. dataType: "json",
  33. data: data,
  34. timeout: 60000,
  35. success: function (msg) {
  36. callback(msg);
  37. },
  38. error: function (xhr, textstatus, thrown) {
  39. alert(xhr)
  40. console.log(xhr)
  41. }
  42. });
  43. };
  44. /**
  45. * 修改数据的ajax-put请求
  46. * @author laixm
  47. */
  48. $.putJSON = function (url, data, callback) {
  49. $.ajax({
  50. url: url,
  51. type: "put",
  52. contentType: "application/json",
  53. dataType: "json",
  54. data: data,
  55. timeout: 20000,
  56. success: function (msg) {
  57. callback(msg);
  58. },
  59. error: function (xhr, textstatus, thrown) {
  60. }
  61. });
  62. };
  63. /**
  64. * 删除数据的ajax-delete请求
  65. * @author laixm
  66. */
  67. $.deleteJSON = function (url, data, callback) {
  68. $.ajax({
  69. url: url,
  70. type: "delete",
  71. contentType: "application/json",
  72. dataType: "json",
  73. data: data,
  74. success: function (msg) {
  75. callback(msg);
  76. },
  77. error: function (xhr, textstatus, thrown) {
  78. }
  79. });
  80. };