If you mean updating scope, you can directly assign to scope from the success callback.
$http({
url: "php/InsertTab.php",
method: "POST",
data: {
'userId': userId,
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data, status, headers, config) {
$scope.myVar = data;
}).error(function(data, status, headers, config) {
});
If you need to show a loading indicator or so, you can use the promise API, which provides a then(success, error)
method, like that:
function MyCtrl($scope) {
$scope.ajaxLoading = true;
$scope.ajaxComplete = function() {
$scope.ajaxLoading = false;
};
$http({
url: "php/InsertTab.php",
method: "POST",
data: {
'userId': userId,
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data, status, headers, config) {
$scope.myVar = data;
}).error(function(data, status, headers, config) {
}).then($scope.ajaxComplete, $scope.ajaxComplete);
}
You can later make this generic using AJAX interceptors. See the AJAX documentation page:
https://docs.angularjs.org/api/ng/service/$http