I'm newbie with JavaScript, so I have a problem to insert html into document using javascript.
Code that trying to insert html into document:
function loadTaskPage(taskId){
fetch("https://localhost:44321/api/Tasks/1")
.then(function(response){
return response.text();
}).then(function(data){
document.body.insertAdjacentHTML('beforeend', data);
}).catch(function(error){
alert(error);
})
}
This code part I took from tutorial, source code of tutorial could be found in this link: http://ift.tt/2v7VhEu
If I will try to open this link https://localhost:44321/api/Tasks/1 in browser I recieve normally styled web page, but when I try to insert it to document, html code got escaped and don't display anything.
Inserted html looks like:
<div id="\"myModal\"" class="\"modal" fade\"="">...
The code below is bootstrap modal copied from code examples. As you see there appeared symbols \" that escapes quotes.
Response with html I reciew from my ASP.Net Web Api with header: text/html
How should I insert this html code into document using javascript?
Aucun commentaire:
Enregistrer un commentaire