The HTML code set as text and not parsed as html code
本问题已经有最佳答案,请猛点这里访问。
我的javascript代码中有以下调用Ajax代码:
1 2 3 | $.get("MyServlet",function(data, status) { $('#ajaxResponse').text(data); }); |
我的元素
1 2 3 4 5 6 7 | <table border="1"> <tr> <td>ID</td> <td>Name</td> <td>Surname</td> </tr> ... |
从文件:
We need to be aware that this method escapes the string provided as
necessary so that it will render correctly in HTML. To do so, it calls
the DOM method .createTextNode(), does not interpret the string as
HTML.
方法:
1 2 3 | $.get("MyServlet",function(data, status) { $('#ajaxResponse').html(data); }); |
jQuery的方法中发现的所有
参考:http://api.jquery.com / HTML /