Reputation: 859
I am having trouble with posting to a URL with GET parameters using Angular's $http.
URL: http://localhost/api/?r=page/product
Now I have to post data to this URL via AJAX. When I try it with the following code it doesn't work.
$http({
url:'api/?r=page/product',
method:'post',
params:{
price:$scope.price
},
});
Where as the same in jQuery Works flawlessly.
$.ajax({
url:'api/?r=page/product',
method:'post',
data:{
price:$scope.price
}
});
What should I add to make it work?
Regards
Upvotes: 0
Views: 75
Reputation: 4936
Try:
$http({
url:'/api',
method:'post',
params: {
r: 'page/product'
},
data:{
price:$scope.price
},
});
you mixed up params with data, params are the query parameters added to the url, data is the data being sent in the request
Upvotes: 2