I am using the $http.get('url') to get the content present in the 'url' present. The html in 'url' is as follows
<html>
<head></head>
<body>
<pre style = "word-wrap: break-word; white-space: pre-wrap;">
<!-- content is present here -->
</pre>
</body>
</html>
When I make a $http.get to this url, I get some data and the required content
GET /TYPE=abvd HTTP 1.1
content required
.0.1234.123 Safari /123.12
Referer: //url of the webpage calling this function
Accept-Encoding:
...............
How do I get rid of this extra information and receive only the content? (I know we can just parse the response but is there a better way of doing it? )
EDIT: The data response I got was seen in google chrome, when I run the same script in IE10, I get the only the "html content" as desired. Why does this difference occur and how do I make process it?
$http.get
returns an HttpPromise, and from it you can get the underlying data like so:
$http.get('url').then(function(response) {
html = response.data;
});
To get even more useful data, you can expand this like so:
$http.get('url').then(
// success handler
function(response) {
var data = response.data,
status = response.status,
header = response.header,
config = response.config;
},
// error handler
function(response) {
var data = response.data,
status = response.status,
header = response.header,
config = response.config;
});
Demo: JSBin
Edit: If there are still HTML issues, you can look into $sce.trustAsHtml(html)
or PhantomJS with references:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With