Angularjs $ http服务,方法JSONP发送数据不起作用

时间:2014-02-14 12:24:09

标签: angularjs

在Angularjs中我们可以使用$ http服务使用方法“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');
      });

1 个答案:

答案 0 :(得分:1)

是的,你可以!见ng.$http。您的url缺少callback参数:

$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');
});