最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I specify JSONP as the dataType in an angular $http service request? - Stack Overflow

programmeradmin1浏览0评论

I'm familiar with using jQuery's $.ajax:

$.ajax({
  url: //twitter endpoint,
  method:"GET",
  dataType:"jsonp",
  success:function() {
    //stuff
  }
});

How can I specify the JSONP datatype to an angular $http service request?

so far I've tried this:

$http.get({
  url: //twitter endpoint,
  dataType: "jsonp",
  success: function(){
    //stuff
  }
});

It hasnt worked though. Any ideas?

I'm familiar with using jQuery's $.ajax:

$.ajax({
  url: //twitter endpoint,
  method:"GET",
  dataType:"jsonp",
  success:function() {
    //stuff
  }
});

How can I specify the JSONP datatype to an angular $http service request?

so far I've tried this:

$http.get({
  url: //twitter endpoint,
  dataType: "jsonp",
  success: function(){
    //stuff
  }
});

It hasnt worked though. Any ideas?

Share Improve this question asked Nov 20, 2013 at 20:46 dopatramandopatraman 13.9k29 gold badges97 silver badges163 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

You can always use $http.jsonp(url).success(function() {} );

$http.jsonp

Try this:

$http({
  method: 'JSONP',
  url: '/someUrl?cb=JSON_CALLBACK'

}).then(function (response) {
  // stuff
});
发布评论

评论列表(0)

  1. 暂无评论