If you're looking to update the scope, one way is to assign directly from the success callback:
$http({
url: "php/UpdateTab.php",
method: "POST",
data: {
'userId': userId,
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data, status, headers, config) {
$scope.updatedVar = data;
}).error(function(data, status, headers, config) {
});
If you want to display a loading indicator or something similar, you can utilize the promise API with then(success, error)
method like this:
function MyCtrl($scope) {
$scope.loading = true;
$scope.loaded = function() {
$scope.loading = false;
};
$http({
url: "php/UpdateTab.php",
method: "POST",
data: {
'userId': userId,
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data, status, headers, config) {
$scope.updatedVar = data;
}).error(function(data, status, headers, config) {
}).then($scope.loaded, $scope.loaded);
}
You can further enhance this by using AJAX interceptors for more generic handling. Check out the AngularJS documentation for more details:
https://docs.angularjs.org/api/ng/service/$http