jqhttpsdk.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. $.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. }
  40. });
  41. };
  42. /**
  43. * 修改数据的ajax-put请求
  44. * @author laixm
  45. */
  46. $.putJSON = function (url, data, callback) {
  47. $.ajax({
  48. url: url,
  49. type: "put",
  50. contentType: "application/json",
  51. dataType: "json",
  52. data: data,
  53. timeout: 20000,
  54. success: function (msg) {
  55. callback(msg);
  56. },
  57. error: function (xhr, textstatus, thrown) {
  58. }
  59. });
  60. };
  61. /**
  62. * 删除数据的ajax-delete请求
  63. * @author laixm
  64. */
  65. $.deleteJSON = function (url, data, callback) {
  66. $.ajax({
  67. url: url,
  68. type: "delete",
  69. contentType: "application/json",
  70. dataType: "json",
  71. data: data,
  72. success: function (msg) {
  73. callback(msg);
  74. },
  75. error: function (xhr, textstatus, thrown) {
  76. }
  77. });
  78. };