jquery - $.ajax like function for React js and Angular js? -


how post data using react , angular?

is there has function $.ajax react , angular?

i mean need post function react , angular

$.ajax{ url:"test.php", type:"post", cache:false, success... etc. 

the angularjs way of calling $http like:

$http({     url: "http://example.appspot.com/rest/app",     method: "post",     data: {"foo":"bar"} }).success(function(data, status, headers, config) {     $scope.data = data; }).error(function(data, status, headers, config) {     $scope.status = status; }); 

or written simpler using shortcut methods:

$http.post("http://example.appspot.com/rest/app", {"foo":"bar"}) .success(function(data, status, headers, config) {     $scope.data = data; }).error(function(data, status, headers, config) {     $scope.status = status; }); 

there number of things notice:

angularjs version more concise (especially using .post() method)

angularjs take care of converting js objects json string , setting headers (those customizable)

callback functions named success , error respectively (also please note parameters of each callback)

the above quick example , pointers, sure check angularjs documentation more: http://docs.angularjs.org/api/ng.$http

from: from jquery $.ajax angular $http

for react: http://andrewhfarmer.com/react-ajax-best-practices/


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -