Javascript 处理包含html代码的xmlhttpResponse时,需要修改锚元素
` reponseText包含html代码 Products是Div元素的Id。Javascript 处理包含html代码的xmlhttpResponse时,需要修改锚元素,javascript,jquery,html,Javascript,Jquery,Html,` reponseText包含html代码 Products是Div元素的Id。 我想在这个div(products)中预先附加所有锚元素,比如http://www.example.com/后跟当前href属性。您只需要在ajax请求页面中指定所需的部分,否则xmlhttp.responseText将返回请求页面中给出的所有HTML和print语句 例如,在JSP的情况下 `var responseText = xmlhttp.responseText; $(reponseText).$(
我想在这个div(products)中预先附加所有锚元素,比如
http://www.example.com/
后跟当前href属性。您只需要在ajax请求页面中指定所需的部分,否则xmlhttp.responseText将返回请求页面中给出的所有HTML和print语句
例如,在JSP的情况下
`var responseText = xmlhttp.responseText;
$(reponseText).$('#products href').each(function(){
this.href = "http://www.example.com" + this.href;
})
阿贾克斯:
xmlhttp.responseText
将返回html标记和打印文本“something”
实际结果将是:“某物”
因此,您需要从请求页面中删除不需要的html/打印语句
<html>
<%
out.print("something")
%>
</html>