0

How can I set the ajax return data type in angular? For instance I can set it easily in jquery if I want the response data to be html.

jquery,

$.ajax({
  url: "script.php",
  type: "GET",
  dataType: "html"
});

angular,

$http({
  method: "get",
  url: "script.php",
  responseType: "html" // does not work
}).then(function(response) {
  $scope.form = response.data;
);

It always returns string or json but what about html or xml?

Run
  • 54,938
  • 169
  • 450
  • 748

1 Answers1

0

According to https://docs.angularjs.org/api/ng/service/$http (and by extension https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#responseType), there is no responseType as html. I suppose document should work though.

budhajeewa
  • 2,268
  • 1
  • 17
  • 19