Home > Web Front-end > HTML Tutorial > Example code directly embedded in form in html

Example code directly embedded in form in html

零下一度
Release: 2017-04-21 18:06:16
Original
1804 people have browsed it

form submission

1, the returned jump page can be directly assigned to a variable on the page (for example, the ajax setting can return the format html) This will provide a display effect for complex logic Very good, a set of logic

2, you can also write the src and other attributes in the tag in the form of byte stream

3, the ajax splicing time is too long, and there are asynchronous rendering problems

A page

1 Direct action submit submission

2 Ajax submission

A, the default return string, (json)

 function submit() {
if (confirm('确实要绑定吗?')) {
form.submit();
return true;
}
return false;
}
Copy after login

B, when it is required to return html, dataType: "html",

is submitted in html form, and 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);//这个返回的是一个跳转的jsp页面,直接嵌入
},
error:function(retMsg){
try{
var ret = eval("("+retMsg.responseText+")");
if(ret.status!=0){
$.zd.alert('',ret.msg);
}
}catch(eee){
}
}
});
} 
 
<p id="data">
     
      </p>
Copy after login

At this time, there is no need to write the @Response() tag in the background , this tag is aimed at returning data in json format

##@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";
}
Copy after login
Students who need to learn html please pay attention php Chinese website

html video tutorial, many html online video tutorials can be watched for free!

The above is the detailed content of Example code directly embedded in form in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template