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

I'm familiar with using jQuery's $.ajax:$.ajax({url: twitter endpoint,method:"GET"

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745190585a4615844.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信