2

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?

dopatraman
  • 13,416
  • 29
  • 90
  • 154

2 Answers2

6

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

$http.jsonp

tymeJV
  • 103,943
  • 14
  • 161
  • 157
0

Try this:

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

}).then(function (response) {
  // stuff
});
Anders
  • 8,307
  • 9
  • 56
  • 88
Cotton
  • 1,157
  • 9
  • 16