Parse Ajax Html Response, And Append Result
i get condition where i need to request page with ajax. and i get HTML as result. parse those HTML result, and append parsed HTML content into current page. let say this HTML cont
Solution 1:
change your dataType from "text" to "html"
Solution 2:
You should skip the textnode.
I got in the console [
Text, <div id="main"></div>, <script type="text/javascript" src="http://script.com/js/script.js"></script>, Text]
so just get jquery(data)[1]
I tried the same thing as you with in test.html :
<html><head></head><body><divid="main"><scripttype="text/javascript"src="http://script.com/js/script.js"></script></div></body></html>
and in another file
<scripttype="text/javascript">
$(document).ready(function(){
jQuery.ajax({
url: './test.html',
type : "POST",
dataType : "html",
success: function(data) {
console.log(jQuery(data)[1]); //Then i got the main div// than append
}
});
});
</script>
Post a Comment for "Parse Ajax Html Response, And Append Result"