点击删除弹出确认框,’是‘异步提交,‘否’不删除,并弹出不提交原因

---------前台JS方法--------
/**
*功能描述:异步删除单条记录
*@param url:删除请求URL
*@param id:记录主键
*@param totalRecords:总记录数
*@param totalPages:总页数
*@param currentPage:当前页码
*/
function deleteRecord(url, id, formId, queryUrl,sessionid) {
	$.messager.confirm('提示', '\u6570\u636e\u5220\u9664\u540e\u4e0d\u53ef\u6062\u590d\uff0c\u786e\u5b9a\u8981\u5220\u9664\u5417?', function(r){
		if(r){
			var params = {id:id,sessionid:sessionid};
			jQuery.post(url, params, function callbackDeleteRecord(data) {
				//把数据解析为json 格式 
				var member = eval("(" + data + ")");
				if (member.success) {
					var queryForm = document.getElementById(formId);
					queryForm.action = queryUrl;
					queryForm.submit();
				} else {
					$.messager.alert("提示","\u7cfb\u7edf\u9519\u8bef,\u5220\u9664\u6570\u636e\u5931\u8d25","error");
				}
			}, "json");
		}
	})
}

-----------后台代码-----------------

/**
	 * 单个删除AmAppAvoidOrg
	 */
	public String delete() {
		String result =null;
		//删除类型(1:同步删除  0:异步删除)
		String type = request.getParameter("type");
		try {
			if ("1".equals(type)) {
				result= ACTION_QUERY;
			}else{
				result= AJAX;
			}
			AmAppAvoidOrg amAppAvoidOrg=this.getModel();
			Long app_id=amAppAvoidOrg.getApp_id();
			request.setAttribute("app_id", app_id);
			this.useAmAppAvoidOrgService.delete(amAppAvoidOrg);
			json = "{success:true}";
		} catch (Exception e) {
			e.printStackTrace();
			json = "{success:false}";
		} 
		return result;



 

你可能感兴趣的:(json,数据,函数,异步,url)