Reputation: 2409
In Angularjs Can we send data using $http service with method "JSONP"
$http({
method: 'JSONP',
url: 'http://plv.localhost/register?callback=JSON_CALLBACK',
data : { name : 'some name' }
}).success(function(data, status , header, config){
console.log('success');
}).error(function(data, status , header, config){
console.log('error');
});
Upvotes: 1
Views: 2547
Reputation: 21758
Yes, you can! See ng.$http
. Your url
is missing the callback
parameter:
$http({
method: 'jsonp',
url: 'http://plv.localhost/register?callback=JSON_CALLBACK',
params: { name: 'some name' }
}).success(function(data, status , header, config) {
console.log('success');
}).error(function(data, status , header, config) {
console.log('error');
});
Upvotes: 1