jqhttpsdk.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * 获取数据ajax-get请求
  3. * @author chanjunkai
  4. */
  5. // var http_ip_prot = 'http://192.168.136.40:4696/'
  6. let http_ip_prot = 'http://192.168.136.40:7724/';
  7. $.GetJSON = function (url, data, callback) {
  8. $.ajax({
  9. url: url,
  10. type: "get",
  11. contentType: "application/json",
  12. dataType: "json",
  13. timeout: 10000,
  14. data: data,
  15. success: function (data) {
  16. callback(data);
  17. }
  18. });
  19. };
  20. /**
  21. * 提交json数据的post请求
  22. * @author laixm
  23. */
  24. $.postJSON = function (url, data, callback) {
  25. $.ajax({
  26. url: url,
  27. type: "post",
  28. contentType: "application/json",
  29. dataType: "json",
  30. data: data,
  31. timeout: 60000,
  32. success: function (msg) {
  33. callback(msg);
  34. },
  35. error: function (xhr, textstatus, thrown) {
  36. }
  37. });
  38. };
  39. /**
  40. * 修改数据的ajax-put请求
  41. * @author laixm
  42. */
  43. $.putJSON = function (url, data, callback) {
  44. $.ajax({
  45. url: url,
  46. type: "put",
  47. contentType: "application/json",
  48. dataType: "json",
  49. data: data,
  50. timeout: 20000,
  51. success: function (msg) {
  52. callback(msg);
  53. },
  54. error: function (xhr, textstatus, thrown) {
  55. }
  56. });
  57. };
  58. /**
  59. * 删除数据的ajax-delete请求
  60. * @author laixm
  61. */
  62. $.deleteJSON = function (url, data, callback) {
  63. $.ajax({
  64. url: url,
  65. type: "delete",
  66. contentType: "application/json",
  67. dataType: "json",
  68. data: data,
  69. success: function (msg) {
  70. callback(msg);
  71. },
  72. error: function (xhr, textstatus, thrown) {
  73. }
  74. });
  75. };