I have an AJAX call to a server that will return an HTML response. This HTML response will include HTML, CSS, and JS. I would like to embed this response on my current page so the user will be able to view the response. I have tried the following, but the CSS from the response is applied to my current page. Is there any way to prevent the CSS from being applied to my current page?
Note that I have no control over the CSS returned by the server. The server can return CSS that targets all element types p { color:red } :(
$.ajax ({
type: TYPE,
contentType: CONTENT_TYPE,
url: URL,
headers: {
firstName: firstName,
lastName: lastName
}
})
.done( function(msg) {
$('#response').html(msg);
})
<div id="response"></div>
Better use of CSS selectors would help. Perhaps wrap the result within a container div and add a class to that. Then your css can be used to only target elements within that div.
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