Anil Gupta
Anil Gupta

Reputation: 2409

Angularjs $http service with method JSONP sending data not working

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

Answers (1)

André Dion
André Dion

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

Related Questions