This article mainly introduces the method of jQuery Validator to verify the Ajax submission form and the method of Ajax passing parameters. The article also mentions how to write the jquery .ajax submission form. For specific example codes, please refer to this article
# The ##serialize() method creates a URL-encoded text string by serializing form values. Instead of passing parameters one by oneThe ajax parameter passing method written in the past$.ajax({ url : "${ctx}/SJStandardDamPartition/insertOrUpdateDamPartition", type : "post", dataType : "json", data: {beginsectionid:function(){ return $('#number option:selected').val(); }, beginelevation:function(){ return $('#onset').val(); }, endelevation:function(){ return $('#end').val(); } }, success : function(result) { } });
var param = $("#standForm").serialize();
$.ajax({
url : "${ctx}/SJStandardStandardInfo/insertOrUpdateStandardInfo",
type : "post",
dataType : "json",
data: param,
success : function(result) {
}
});
$("#submitButton").click(function(){ //序列化表单 var param = $("#leaveSave").serialize(); $.ajax({ url : "leaveSave.action", type : "post", dataType : "json", data: param, success : function(result) { if(result=='success') { location.href='allRequisitionList.action'; } else if(result.startWith("error_")){ $("#errorMessage").html(result.substring(6)); } else { //返回的结果转换成JSON数据 var jsonObj = eval('('+result+')'); startTime = $("#startdate").val(); endTime = $("#enddate").val(); hour = jsonObj.hour; reason = jsonObj.reason; replaceDom(startTime,endTime,hour,reason); } } }); });
Principles of Ajax cross-domain requests (graphic tutorial)
dwz How to remove ajaxloading (graphic tutorial)
Ajax cooperates with node js multer to implement file upload function
The above is the detailed content of jQuery Validator verifies Ajax form submission method and Ajax parameter passing method (picture and text tutorial). For more information, please follow other related articles on the PHP Chinese website!