pm_ajax.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Created by Mai on 2017/3/8.
  3. */
  4. // 获取用户全部项目数据
  5. var GetAllProjectData = function (callback) {
  6. $.ajax({
  7. type:"POST",
  8. url: '/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: '/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: '/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. }