admin管理员组

文章数量:1415460

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

本文标签: javascriptHow do I specify JSONP as the dataType in an angular http service requestStack Overflow