I am reading Html from webpage inside div content using jquery
HTML Code
<div id="content">
Html Code
</div>
Jquery Code
var htmlContent = $("#content").html();
and saving it directly into database using Ajax Request. But if somebody inject the Html or Javascript code into the Html Content of the page, that is also getting saved into database.
When next time html is loaded on page it is infected with XSS attack. Is there any way I can prevent XSS attack..