form submit
1. The returned jump page can be directly assigned to a variable of the page (for example, the return format of ajax can be set to html), which is very effective for displaying complex logic. A set of logic
2. Attributes such as src in the tag can also be written in the form of a byte stream
3, Ajax splicing time is too long, there are asynchronous rendering problems
a page
1 Direct action submit to submit
2 ajax submission
A, default return string, (json)
function submit() {
if (confirm('Are you sure you want to bind?')) {
form.submit();
return true;
}
return false;
}
B, when the return type html is required, dataType: "html",
Submitted in html form, the return is directly embedded in the page
function loadData(){
//alert($("#search").formSerialize());
$.ajax({
url:"getAccountData",
type:"post",
dataType:"html",
cache:false,
data:$("#search").formSerialize(),//url传参形式,&&&
success:function(data){
$("#data").html(data);//This returns a jumped jsp page, directly embedded
},
error:function(retMsg){
try{
var ret = eval("("+retMsg.responseText+")");
if(ret.status!=0){
$.zd.alert('',ret.msg);
}
}catch(eee){
}
}
});
}
<div id="data">
</div>
这个时候后台不必写@Response()标签,这个标签针对的是json格式的数据返回
@RequestMapping(value = "/getAccountData")
public String getAccountData(Model model,TbCusUserBeanVo tbCusUserBeanVo, HttpServletRequest request, HttpSession session) throws Exception {
Map<String,Object> param = new HashMap<String,Object>();
CASUtil.getCurrentUserName(request, session);
param.put("CUSTOMER_KEY", customerKey);
param.put("MAN", tbCusUserBeanVo.getMan());
param.put("CUS_USER_ID", tbCusUserBeanVo.getCusUserId().toUpperCase());
param.put("CUS_USER_STATUS", tbCusUserBeanVo.getCusUserStatus());
model.addAttribute("list",accountService.getOperateUserByCustomerKey(param));
return "myaccount/operateUser/operateUserListData";
}