pm_ajax.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * Created by Mai on 2017/3/8.
  3. */
  4. // 获取用户全部项目数据
  5. var GetAllProjectData = function (callback) {
  6. $.ajax({
  7. type:"POST",
  8. url: '/pm/api/getProjects',
  9. data: {'data': JSON.stringify({"user_id": userID})},
  10. dataType: 'json',
  11. cache: false,
  12. timeout: 50000,
  13. success: function(result){
  14. if (result.error === 0) {
  15. callback(result.data);
  16. //Tree = $.fn.treeTable.init(table, ProjTreeSetting, result.data);
  17. } else {
  18. alert('error: ' + result.message);
  19. }
  20. },
  21. error: function(jqXHR, textStatus, errorThrown){
  22. alert('error ' + textStatus + " " + errorThrown);
  23. }
  24. });
  25. }
  26. // 更新数据到服务器
  27. var UpdateProjectData = function (updateData, callback) {
  28. $.ajax({
  29. type:"POST",
  30. url: '/pm/api/updateProjects',
  31. data: {'data': JSON.stringify({"user_id": userID, "updateData": updateData})},
  32. dataType: 'json',
  33. cache: false,
  34. timeout: 50000,
  35. success: function(result){
  36. if (result.error === 0) {
  37. callback(result.data);
  38. } else {
  39. alert('error: ' + result.message);
  40. }
  41. },
  42. error: function(jqXHR, textStatus, errorThrown){
  43. alert('error ' + textStatus + " " + errorThrown);
  44. }
  45. });
  46. };
  47. // 重命名项目
  48. var RenameProject = function(projId, newName, callback) {
  49. $.ajax({
  50. type: "POST",
  51. url: '/pm/api/renameProject',
  52. data: {'data': JSON.stringify({"user_id": userID, "id": projId, "newName": newName})},
  53. dataType: 'json',
  54. cache: false,
  55. timeout: 15000,
  56. success: function(result){
  57. if (result.error === 0) {
  58. callback();
  59. } else {
  60. alert('error' + result.message);
  61. }
  62. },
  63. error: function(iqXHR, textStatus, errorThrown){
  64. alert('error ' + textStatus + " " + errorThrown)
  65. }
  66. });
  67. };
  68. // 打开项目前,提交数据
  69. var BeforeOpenProject = function (projId, updateData, callback) {
  70. $.ajax({
  71. type: "POST",
  72. url: '/pm/api/beforeOpenProject',
  73. data: {'data': JSON.stringify({"user_id": userID, "proj_id": projId, "updateData": updateData})},
  74. dataType: 'json',
  75. cache: false,
  76. timeout: 15000,
  77. success: function (result) {
  78. if (result.error === 0) {
  79. callback();
  80. } else {
  81. alert('error' + result.message);
  82. }
  83. },
  84. error: function(iqXHR, textStatus, errorThrown){
  85. alert('error ' + textStatus + " " + errorThrown)
  86. }
  87. });
  88. }