1.post
function deleCustomsVender(cvId) {
var url = "$popSellerAdminModule.getTarget("/customs/shop/customs_deleCustomsVender.action?_charset_=utf-8")";
if(confirm("确定要解除海关对该拍卖店铺的管理授权?解除后该店铺将不受海关账号控制。")) {
jQuery.post(url
,{
"customsVenderId":cvId
} , function (data) {
if(data!="false"){
alert("解除授权成功!");
$("#deleCustomsVender_"+cvId).hide();
}else {
alert("解除授权失败,请稍后再试");
}
}, 'text');
}
}
function operateOpenStatus(openStatus,customsId) {
var url = "$popSellerAdminModule.getTarget("/customs/customs_operateOpenStatus.action?_charset_=utf-8")";
var msg = "";
if (openStatus == 1) {
msg = "停用海关不会自动停用关联的店铺,关联店铺需要单独处理,确定要停用该海关吗?";
} else if (openStatus == 2) {
msg = "确定启用该海关账号?";
}
if(confirm(msg)) {
jQuery.post(url
,{
"customsId":customsId,
"openStatus":openStatus
} , function (data) {
if(data!="false"){
alert("操作成功!");
window.location.reload(true);
}else {
alert("操作失败,请稍后再试");
}
}, 'text');
}
}
protected javax.servlet.http.HttpServletResponse response;
@HrmPrivilege(code = HrmPurviewConstants.POP_MAN_CUSTOMS_ACCOUNT_MANAGE_ADD)
public void deleCustomsAccount() throws IOException {
String pin = WebHelper.getPin();
if (StringUtils.isNotBlank(pin)){
response.getWriter().write(customsService.deleCustomsAccountByAccountId(accountId)==0?"false":pin);
}else{
response.getWriter().write("false");
}
}
2.ajax
jQuery("#shopform1").validate({
rules: {
"customsFormBean.customsName": {
required: true,
zh_CnLength:100
//maxlength: 50
},
"customsFormBean.licenseNo": {
//required: true,
validLicenseNo:true,
maxlength: 50
},
"customsFormBean.principal":{
required: true
},
"customsFormBean.remark": {
zh_CnLength:200
}
},
messages: {
"customsFormBean.customsName": {
required: "请输入海关名称"
},
"customsFormBean.licenseNo": {
// required: "请输入营业执照编号",
validLicenseNo:"请输入正确的营业执照编号"
},
"customsFormBean.principal":{
required: "请选择招商人员"
}
},
submitHandler: function (form) {
var customsName = jQuery("[name='customsFormBean.customsName']").val();
var licenseNo = jQuery("[name='customsFormBean.licenseNo']").val();
var principal = jQuery("[name='customsFormBean.principal']").val();
var customsId = jQuery("[name='customsId']").val();
var remark = jQuery("[name='customsFormBean.remark']").val();
jQuery.blockUI({message:'提交中,请稍候...'});
jQuery.ajax({
type: "POST",
dataType: "json",
url: '$popSellerAdminModule.getTarget("/json/updateCustoms/doUpdateCustoms.action?_charset_=utf-8")',
data: {"customsFormBean.customsName": customsName, "customsFormBean.licenseNo": licenseNo,
"customsFormBean.principal": principal, "customsId": customsId,
"customsFormBean.remark":remark
},
success: function (data) {
jQuery.unblockUI();
if(data.succeed) {
alert("修改成功!");
window.location.reload(true);
}else{
alert(data.errorContent)
}
},
error:function(data){
jQuery.unblockUI();
alert("修改失败!");
}
});
}
});
===============================================================
jQuery(document).ready(function() {
jQuery("#edit1").click(function() {
jQuery('#div1').attr('class', 'hide');
jQuery('#shopform1').attr('class', '');
});
/**
* 计算含有中文的字符串长度
*/
jQuery.validator.addMethod("zh_CnLength",function(value,element,param){
value = value.replace(/(^\s*)|(\s*$)/g, "");
String.prototype.getBytes = function() {
var cArr = this.match(/[^\x00-\xff]/ig);
return this.length + (cArr == null ? 0 : cArr.length);
}
var length = value.getBytes();
if(length>param){
return false;
}
return true;
},"请输入一个长度最多是 {0} 的字符串,一个中文算两个长度");
/**
* 自定义验证营业执照编号
*/
jQuery.validator.addMethod("validLicenseNo", function (value, element) {
var pattern = new RegExp("^[0-9]{15}$");
return this.optional(element) || (pattern.test(value));
},"请输入正确的营业执照编号");
jQuery("#shopform1").validate({
rules: {
"customsFormBean.customsName": {
required: true,
zh_CnLength:100
//maxlength: 50
},
"customsFormBean.licenseNo": {
//required: true,
validLicenseNo:true,
maxlength: 50
},
"customsFormBean.principal":{
required: true
},
"customsFormBean.remark": {
zh_CnLength:200
}
},
messages: {
"customsFormBean.customsName": {
required: "请输入海关名称"
},
"customsFormBean.licenseNo": {
// required: "请输入营业执照编号",
validLicenseNo:"请输入正确的营业执照编号"
},
"customsFormBean.principal":{
required: "请选择招商人员"
}
},
submitHandler: function (form) {
var customsName = jQuery("[name='customsFormBean.customsName']").val();
var licenseNo = jQuery("[name='customsFormBean.licenseNo']").val();
var principal = jQuery("[name='customsFormBean.principal']").val();
var customsId = jQuery("[name='customsId']").val();
var remark = jQuery("[name='customsFormBean.remark']").val();
jQuery.blockUI({message:'提交中,请稍候...'});
jQuery.ajax({
type: "POST",
dataType: "json",
url: '$popSellerAdminModule.getTarget("/json/updateCustoms/doUpdateCustoms.action?_charset_=utf-8")',
data: {"customsFormBean.customsName": customsName, "customsFormBean.licenseNo": licenseNo,
"customsFormBean.principal": principal, "customsId": customsId,
"customsFormBean.remark":remark
},
success: function (data) {
jQuery.unblockUI();
if(data.succeed) {
alert("修改成功!");
window.location.reload(true);
}else{
alert(data.errorContent)
}
},
error:function(data){
jQuery.unblockUI();
alert("修改失败!");
}
});
}
});
});
<package name="jsonAddCustoms" namespace="/json/addCustoms" extends="json-protected-default">
<action name="*" method="{1}" class="com.jd.pop.customs.web.action.CustomsAction">
<result name="doAddCustoms" type="json">
<param name="ignoreHierarchy">true</param>
<param name="excludeNullProperties">true</param>
<param name="root">baseOperateJson</param>
</result>
</action>
</package>
<!-- 处理json方法中需要获取到当前登录,则用此package-->
<package name="json-protected-default" extends="illegalBase">
<result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult"/>
</result-types>
<interceptors>
<interceptor name="json" class="org.apache.struts2.json.JSONInterceptor"/>
</interceptors>
</package>
<package name="illegalBase" extends="struts-default">
<result-types>
<result-type name="velocity" class="com.jd.common.struts.velocity.VelocityLayoutResult" default="true" />
</result-types>
<interceptors>
<interceptor name="monitoring" class="net.bull.javamelody.StrutsInterceptor"/>
<interceptor name="loginContext" class="com.jd.pop.admin.web.interceptor.AdminLoginContextInterceptor"/>
<interceptor-stack name="strutsDefaultStack">
<interceptor-ref name="monitoring"/>
<interceptor-ref name="exception" />
<interceptor-ref name="alias" />
<interceptor-ref name="servletConfig" />
<interceptor-ref name="i18n" />
<interceptor-ref name="prepare" />
<interceptor-ref name="chain" />
<interceptor-ref name="debugging" />
<interceptor-ref name="scopedModelDriven" />
<interceptor-ref name="modelDriven" />
<interceptor-ref name="fileUpload">
<param name="maximumSize">4194304</param><!--单个文件最大4M-->
<param name="allowedTypes">image/x-png,image/png,image/gif,image/jpeg,image/jpg,image/pjpeg,application/x-shockwave-flash,application/octet-stream,application/vnd.ms-excel,application/msword,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/zip</param>
<param name="allowedExtensions">jpg,jpeg,png,gif,txt,swf,xls,xlsx,doc,docx,zip,pdf</param>
</interceptor-ref>
<interceptor-ref name="checkbox" />
<interceptor-ref name="multiselect" />
<interceptor-ref name="staticParams" />
<interceptor-ref name="actionMappingParams" />
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*,.*\\u0023.*</param>
</interceptor-ref>
<interceptor-ref name="conversionError" />
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
</interceptor-stack>
<interceptor-stack name="illegalInterceptor">
<interceptor-ref name="strutsDefaultStack" />
<interceptor-ref name="loginContext" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="illegalInterceptor" />
<global-results>
<result name="exception">/WEB-INF/vm/error.vm</result>
<result name="input">/WEB-INF/vm/paramError.vm</result>
<result name="error">/WEB-INF/vm/error.vm</result>
<result name="illegal">/WEB-INF/vm/illegal.vm</result>
<result name="login_error">/WEB-INF/vm/loginerror.vm</result>
<result name="login" type="redirect">${loginUrl}</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="exception" />
</global-exception-mappings>
</package>
private BaseOperateJson baseOperateJson;
public BaseOperateJson getBaseOperateJson() {
return baseOperateJson;
}
public void setBaseOperateJson(BaseOperateJson baseOperateJson) {
this.baseOperateJson = baseOperateJson;
}
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import java.io.Serializable;
/**
* BaseOperateJson
* @author @shaodong
*/
@SuppressWarnings("unused")
public class BaseOperateJson implements Serializable{
private boolean succeed;
private String errorCode;
private String errorContent;
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorContent() {
return errorContent;
}
public void setErrorContent(String errorContent) {
this.errorContent = errorContent;
}
public boolean isSucceed() {
return succeed;
}
public void setSucceed(boolean succeed) {
this.succeed = succeed;
}
public BaseOperateJson() {}
public BaseOperateJson(boolean succeed, String errorCode, String errorContent) {
this.succeed = succeed;
this.errorCode = errorCode;
this.errorContent = errorContent;
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
@HrmPrivilege(code = HrmPurviewConstants.POP_MAN_CUSTOMS_MANAGE_DO_UPDATE)
public String doUpdateCustoms(){
baseOperateJson = new BaseOperateJson();
try{
Result result = customsService.updateCustoms(customsFormBean, customsId);
if(result.getSuccess()){
baseOperateJson.setSucceed(true);
String customsId=String.valueOf(result.get("customsId"));
baseOperateJson.setErrorCode(customsId);
}else{
baseOperateJson.setSucceed(false);
String errorCode=result.getResultCode();
baseOperateJson.setErrorCode(errorCode);
baseOperateJson.setErrorContent(getText(errorCode));
log.error(CustomsAction.class.getSimpleName()+"修改海关信息失败"+baseOperateJson+getText(errorCode));
}
}catch (Exception ex){
baseOperateJson.setSucceed(false);
String errorCode= ResultCode.SYSTEM_ERROR;
baseOperateJson.setErrorCode(errorCode);
baseOperateJson.setErrorContent(getText(errorCode));
log.error(CustomsAction.class.getSimpleName()+"修改海关信息失败"+baseOperateJson,ex);
}
return "doUpdateCustoms";
}
@HrmPrivilege(code = HrmPurviewConstants.POP_MAN_CUSTOMS_MANAGE_ADD)
public String doAddCustoms() {
baseOperateJson = new BaseOperateJson();
try{
Result result = customsService.createCustoms(customsFormBean);
if(result.getSuccess()){
baseOperateJson.setSucceed(true);
String customsId=String.valueOf(result.get("customsId"));
baseOperateJson.setErrorCode(customsId);
}else{
baseOperateJson.setSucceed(false);
String errorCode=result.getResultCode();
baseOperateJson.setErrorCode(errorCode);
baseOperateJson.setErrorContent(getText(errorCode));
log.error(CustomsAction.class.getSimpleName()+"创建海关失败"+baseOperateJson+getText(errorCode));
}
}catch (Exception ex){
baseOperateJson.setSucceed(false);
String errorCode= ResultCode.SYSTEM_ERROR;
baseOperateJson.setErrorCode(errorCode);
baseOperateJson.setErrorContent(getText(errorCode));
log.error(CustomsAction.class.getSimpleName()+"创建海关失败"+baseOperateJson,ex);
}
return "doAddCustoms";
}
================================================
jquery.getJson跨域调用及防止重复提交JS
function applyCheckAuth(selectId, opTime){ // var url = "/sellerauth/sellerauth_applyCheckAuth.action?opTime="+opTime; var url = "/json/sellerauth/sellerauth_applyCheckAuth.action?opTime="+opTime; if (!checkSubmit()) { return false; } // if(confirm("确定申请考核认证吗?")) // { jQuery.getJSON(url, function(json) { checkSubmitFlg = false; // alert("申请考核认证成功!!"); window.location.href = "/sellerauth/sellerauth_sellerAuthList.action"; // if (json != null && json != '') { // replaceDivData(selectId, json); // } }); // } //var url = "/json/sellerauth/sellerauth_applyCheckAuth.action?opTime="+opTime; //jQuery.getJSON(url, function(json) { // if (json != null && json != '') { // replaceDivData(selectId, json); // } //}); }
var checkSubmitFlg = false; function checkSubmit() { if (checkSubmitFlg == true) { return false; } checkSubmitFlg = true; return true; }
var replaceDivData = function(selectId,divJsonObj){ var jqId = "#"+selectId; if(jQuery(jqId).length=1){ jQuery.each(divJsonObj, function(index, entry) { if(entry.name!=undefined){ jQuery(jqId).html("<option value='"+entry.id+"'>"+entry.name+"</option>"); } }) } }
相关推荐
// 2 使用$.ajax发送fd // 需要指定两个属性 // - processData : false // - contentType : false $.ajax({ method : 'POST', url : '/ajax_Day5/datas03.php', data : fd, success : function (data) { ...
主要介绍了jQuery+ajax实现动态添加表格tr td功能,结合实例形式分析了jQuery基于ajax动态创建页面table元素相关操作技巧,需要的朋友可以参考下
ajax里response返回的数据是一个二维数组,比如这样的[{key,val},{key,val},{key,val}],这个就是传说中的json数据了,以这样的形式数据传到前台,实现菜单联动下拉框;具体怎么样,详情请仔细查看以下内容
jquery中使用ajax调用一般处理程序中的接口,分带参和不带参两种不同形式
主要介绍了php+jQuery ajax实现的实时刷新显示数据功能,结合实例形式分析了php结合jQuery ajax实时刷新读取显示数据库数据相关操作技巧,需要的朋友可以参考下
jQuery ajax中数据以键值对(Key/Value)的形式发送到服务器,使用ajax提交表单数据时可以使用jQuery ajax的serialize() 方法表单序列化为键值对(key1=value1&key2=value2…)后提交。serialize() 方法使用标准的 ...
ajax从后台读json数据,jquery在页面简析,以表格的形式出现,局部刷新
本文实例讲述了jquery ajax 请求小技巧。分享给大家供大家参考,具体如下: jquery 是一个非常好用的js框架,它为我们提供了很多工具。启动异步请求就是很好用的一个工具 官方推荐的ajax 请求格式 $.ajax({ url:...
jQuery中使用Ajax获取JSON格式数据示例代码,文档的形式了解json的使用!
使用ajax时,常常需要拼装input数据为’name=abc&sex=1’这种形式,用JQuery的serialize方法可以轻松的完成这个工作! jQuery ajax – serialize() 方法定义和用法 serialize() 方法通过序列化表单值,创建 URL 编码...
主要介绍了jQuery+ajax简单实现文件上传的方法,结合实例形式简单分析了jQuery基于ajax的post方法进行文件传输及asp.net后台处理技巧,需要的朋友可以参考下
主要介绍了jQuery AJAX应用,结合实例形式总结分析了jQuery 使用AJAX访问各种格式数据相关应用操作实现技巧,需要的朋友可以参考下
JSON 形式 编写规范JSON 形式 编写规范JSON 形式 编写规范
最近在使用JQuery的ajax方法时,要求返回的数据为json数据,在处理的过程中遇到下面的几个问题,那就是采用不同的方式来生成json数据的时候,在$.ajax方法中应该是如何来处理的,下面依次来进行说明,由于本人使用的...
主要介绍了jQuery基于Ajax实现读取XML数据功能,结合实例形式分析了jQuery基于ajax的get方式获取xml文件数据并输出显示相关操作技巧,需要的朋友可以参考下
jQuery确实是一个挺好的轻量级的JS框架,能帮助我们快速的开发JS应用,并在一定程度上改变了我们写JavaScript代码的习惯。 废话少说,直接进入正题,我们先来分析一下失败的...1)可以使用jquery创建表单并提交实现文件
主要介绍了jquery+ajax实现省市区三级联动效果,结合实例形式分析了jQuery结合ajax实现省市区三级联动功能的具体步骤与相关操作技巧,需要的朋友可以参考下
主要介绍了jQuery+ajax实现批量删除功能,结合完整实例形式分析了jQuery+ajax结合bootstrap与layer.js插件实现的批量删除与交互功能相关操作技巧,需要的朋友可以参考下
主要介绍了基于jQuery使用Ajax动态执行模糊查询功能,通过实例代码相结合的形式给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下