main_ajax.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * Created by Mai on 2017/3/10.
  3. */
  4. var PullData = function (url, data, successCallback, errorCallback) {
  5. $.ajax({
  6. type:"POST",
  7. url: url,
  8. data: {'data': JSON.stringify(data)},
  9. dataType: 'json',
  10. cache: false,
  11. timeout: 50000,
  12. success: function(result){
  13. if (result.error === 0) {
  14. successCallback(result.data);
  15. } else {
  16. alert('error: ' + result.message);
  17. errorCallback();
  18. }
  19. },
  20. error: function(jqXHR, textStatus, errorThrown){
  21. alert('error ' + textStatus + " " + errorThrown);
  22. errorCallback();
  23. }
  24. });
  25. };
  26. var GetProject = function (proj_id, callback) {
  27. $.ajax({
  28. type:"POST",
  29. url: '/pm/api/getProject',
  30. data: {'data': JSON.stringify({"user_id": userID, "proj_id": proj_id})},
  31. dataType: 'json',
  32. cache: false,
  33. timeout: 50000,
  34. success: function(result){
  35. if (result.error === 0) {
  36. callback(result.data);
  37. } else {
  38. alert('error: ' + result.message);
  39. }
  40. },
  41. error: function(jqXHR, textStatus, errorThrown){
  42. alert('error ' + textStatus + " " + errorThrown);
  43. }
  44. });
  45. };
  46. var GetBills = function (proj_id, callback) {
  47. $.ajax({
  48. type: "POST",
  49. url: '/getBills',
  50. data: {'data': JSON.stringify({"user_id": userID, "proj_id": proj_id})},
  51. dataType: 'json',
  52. cache: false,
  53. timeout: 50000,
  54. success: function (result) {
  55. if (result.error === 0) {
  56. callback(result.data);
  57. } else {
  58. alert('error: ' + result.message);
  59. }
  60. },
  61. error: function(jqXHR, textStatus, errorThrown){
  62. alert('error ' + textStatus + " " + errorThrown);
  63. }
  64. });
  65. };
  66. var GetRations = function (proj_id, callback) {
  67. $.ajax({
  68. type: "POST",
  69. url: '/getRations',
  70. data: {'data': JSON.stringify({"user_id": userID, "proj_id": proj_id})},
  71. dataType: 'json',
  72. cache: false,
  73. timeout: 50000,
  74. success: function (result) {
  75. if (result.error === 0) {
  76. callback(result.data);
  77. } else {
  78. alert('error: ' + result.message);
  79. }
  80. },
  81. error: function(jqXHR, textStatus, errorThrown){
  82. alert('error ' + textStatus + " " + errorThrown);
  83. }
  84. });
  85. };