angularjs http和ajax,Angularjs $http VS jquery $.ajax

  • Post author:
  • Post category:其他


Both are same

$http is referred from angular.js script

$.ajax is referred from jquery script

and $http does not support async:false

$.ajax supports async:false

You can do it by using angular.js in this way

$http.get(‘server.php’).success(function(response) {

$scope.contacts = response.data;

}).error(function(error)

{

//some code

});

but async: true, is not supported in angular.js.

If you need stop asynchronous callback, then you must use $.ajax way

More details please see this discussion : from jquery $.ajax to angular $http

Edit:

How to show hide in angular js

xx

$http.get(‘server.php’).success(function(response) {

$scope.contacts = response.data;

$scope.IsShow=true;

$scope.$apply();

}).error(function(error)

{

$scope.IsShow=false;

$scope.$apply();

});