Advertisement
Guest User

Untitled

a guest
Jun 6th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. mobileApp.factory('getSettings', function($http, $q) {
  2. var promise1 = $http.get('settings.json', {
  3. cache: true
  4. });
  5. var promise2 = $http.get('applicationSettings.json', {
  6. cache: true
  7. });
  8. return $q.all([promise1, promise2]);
  9. });
  10.  
  11.  
  12. $scope.save = function(foo) {
  13.  
  14. if (foo == 'app') {
  15. $.ajax({
  16. method: 'POST',
  17. url: 'saveSettings.php',
  18. data: {
  19. type: 'app',
  20. reportsA: $scope.reportsA,
  21. reportsB: $scope.reportsB,
  22. insightA: $scope.insightA,
  23. insightB: $scope.insightB,
  24. insightC: $scope.insightC
  25. },
  26. success: function(data, textStatus, jqXHR) {
  27. alert("Successfully saved.");
  28. },
  29. error: function(jqXHR, textStatus, errorThrown) {
  30. alert("Error.");
  31. }
  32. });
  33. } else if (foo == 'server') {
  34. $.ajax({
  35. method: 'POST',
  36. url: 'saveSettings.php',
  37. data: {
  38. type: 'server',
  39. address: $('#serverAddress').val(),
  40. port: $('#serverPort').val(),
  41. username: $('#userName').val(),
  42. password: $('#password').val()
  43. },
  44. success: function(data, textStatus, jqXHR) {
  45. alert("Successfully saved.");
  46. },
  47. error: function(jqXHR, textStatus, errorThrown) {
  48. alert("Error.");
  49. }
  50. });
  51. } else {
  52. alert("An error occured.");
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement