I need to process some angular http post response data which is a web page to replace a div tag of the current web page with a selected div tag from the response page. Here is my code:
<div id="content"></div>
<script>
var app = angular.module("app", []);
app.controller("cntr", function($scope, $http) {
$scope.myfunction = function(){
var url = '/webApp';
var data = {'data':$scope.mydata};
var config = {headers:{'Content-Type':'application/json'}};
$http.post(url,data,config)
.then(function(response){
$("#content").html(response.data.getElementById('content'));
console.log(response.data);
},
function(response){
console.log(response.data);
});
}
});
</script>
From the console log, i get getElementById is not a function But using
$("#maincontent").html(response.data);
console.log(response.data);
I get the page displayed showing that it is a web page received but this time, the div element is filled with the whole web page. My question is how do I get to process or parse the response data web page with a better alternative to the getElementById function?