jqhttpsdk.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * 获取数据ajax-get请求
  3. * @author chanjunkai
  4. */
  5. http_ip_port = 'http://47.107.129.126:6639';
  6. // http_ip_port = 'http://192.168.136.35:8800';
  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. };