type: "post",
url : "/manager/mobileSet.do?method=replaceCss",
dataType:'json',
/**
*colorType:颜色类型
*/
data:'colorType='+color,
success: function(result){
alert(result)//这里我想接收到action里边的字符串,怎么写 ?
}
})
后台java代码:
String result = “xxxxxxxxxxxxxxx”
PrintWriter out = this.servletResponse.getWriter()
out.write(result)
<html><head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").replaceWith(function(){
return "<div class='go' style='color:red'>Hello World!</div>"
})
$('#t').replaceWith("<style>.go{font-size:3em}</style>")
})
})
</script>
</head>
<body>
<p>这是一个段落。</p>
<p>这是另一个段落。</p>
<div id="t">2</div>
<button class="btn1">用新的 p 元素替换所有段落</button>
</body>
</html>