I use jQuery and ajax for REST API call and set the response to iframe. The target url returns html. It was successful but iframe shows plain page without any text formatting and other functionality. I have attached the images of actual and expected page result (part of page).
Do you how what is wrong with my code? I'm open for any suggestions or if you have better approach to get my expected result.
Below are my codes:
function loadPage()
{
$.ajax({
url: 'URL',
type: 'GET',
headers: {
'Authorization': 'Basic 123eewd45'
},
xhrFields: {
withCredentials: false
},
dataType: 'html',
success: function(data) {
$('#myiframe').contents().find('html').html(data);
}
});
}
Iframe:
<iframe onload="loadPage()"
id="myiframe">
</iframe>
Thank you!