Jquery的ajax获取action中的返回值msg
js部分:
functioncheck(){
$.ajax({
type:"POST",
url:"myCloudWantseeListHD.action",
data:"type=2&kind=1&id=1",
async:false,
cache:false,
success:function(msg){
alert(msg);
},
error:function(e){
alert("error");
}
});
}
注意:
async是asynchronous[异步]的缩写,它是一个bool值默认为true。当async为true时,先不管ajax请求是否完成都要向下执行。同步请求要临时锁定浏览器,当请求正在执行时不执行任何动作。
action中的java关键code:
Stringmsg="fa";
HttpServletResponseresponse=ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf-8");
PrintWriterout=response.getWriter();
out.print(msg);
out.flush();
out.close();
相关推荐
83510998 2020-07-18
TONIYH 2020-07-22
wcqwcq 2020-06-26
delmarks 2020-06-14
ppsurcao 2020-06-14
tthappyer 2020-06-07
kentrl 2020-11-10
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo
ajaxyan 2020-11-09
zndy0 2020-11-03
学留痕 2020-09-20
Richardxx 2020-11-09
learningever 2020-09-19
chongxiaocheng 2020-08-16
ajaxhe 2020-08-16
lyqdanang 2020-08-16
curiousL 2020-08-03