Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mobileApp.factory('getSettings', function($http, $q) {
- var promise1 = $http.get('settings.json', {
- cache: true
- });
- var promise2 = $http.get('applicationSettings.json', {
- cache: true
- });
- return $q.all([promise1, promise2]);
- });
- $scope.save = function(foo) {
- if (foo == 'app') {
- $.ajax({
- method: 'POST',
- url: 'saveSettings.php',
- data: {
- type: 'app',
- reportsA: $scope.reportsA,
- reportsB: $scope.reportsB,
- insightA: $scope.insightA,
- insightB: $scope.insightB,
- insightC: $scope.insightC
- },
- success: function(data, textStatus, jqXHR) {
- alert("Successfully saved.");
- },
- error: function(jqXHR, textStatus, errorThrown) {
- alert("Error.");
- }
- });
- } else if (foo == 'server') {
- $.ajax({
- method: 'POST',
- url: 'saveSettings.php',
- data: {
- type: 'server',
- address: $('#serverAddress').val(),
- port: $('#serverPort').val(),
- username: $('#userName').val(),
- password: $('#password').val()
- },
- success: function(data, textStatus, jqXHR) {
- alert("Successfully saved.");
- },
- error: function(jqXHR, textStatus, errorThrown) {
- alert("Error.");
- }
- });
- } else {
- alert("An error occured.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement