1 //eg:
2 // var data ={
3 // id: id,
4 // typeName: mame,
5 // getcCity:city
6 // }
7 //2.url:需要传到后台的url
8 //3.callback :回调函数
9 //+++++++++++++++++++++++Demo:+++++++++++++++++++++++++++++++++++
10 //var data ={
11 // id: id,
12 // typeName: name
13 //}
14 //var url = encodeURI("${pageContext.request.contextPath}/ajax/certificate/saveCertificateType");
15 //actionRequest(data,url,function(data){
16 // if (data.successed) {
17 // toNotification("提示!","操作成功!", "success");
18 // //刷新表格
19 // initnewAttributeTable();
20 // }else {
21 // toNotification("操作失败!", data.message, "error");
22 // }
23 //});
24 //+++++++++++++++++++++++Demo:+++++++++++++++++++++++++++++++++++
25 //*****************************ajax代码封装************************************
26 function actionRequest(data,url,callback){
27 actionRequestExt(data,url,1,callback)
28 }
29
30 //重载ajax方法
31 function actionRequestExt(data,url,areaId,callback){
32 var json = {
33 'actionId': getActionId(),
34 'areaId': areaId,
35 'data':data
36 };
37 $.ajax({
38 type: "post",
39 url: url,
40 data: JSON.stringify(json),
41 dataType: "json",
42 contentType: 'application/json;charset=utf-8',
43 success: function (data) {
44 //回调函数
45 callback.call(this,data);
46 },
47 error: function (xhr, status, statusText) {
48 toNotification("异常!",statusText, "error");
49 $('.sa-button-container .cancel').click();
50 }
51 });
52 }
53 //获得标识
54 function getActionId() {
55 return new Date().getTime();
56 }