The page code and Action Code are listed here for reference:
Page code (jQuery ajax asynchronous request for data ):
[Javascript]
<Span style = "font-family: Microsoft YaHei; font-size: 13px;"> // save decision information
Function savedemo (){
Var rowid = checkSelected ();
Var rowData = jQuery ("# list"). jqGrid ('getrowdata ',
Rowid );
Var processIsRight = rowData ["processIsRight"];
If (rowid =-1) {alert ("only one recommended solution can be selected"); return ;}
Else if (processIsRight = 0) {// check whether the process is faulty
Alert ("there are no default persons for tasks under this process scheme, please carefully check this process scheme"); return;
}
// Determine whether the decision maker is selected: Required
Var _ decisionMaker = $ ("# businessModule"). find ("option: selected"). val ();
If (_ decisionMaker = ''| _ decisionMaker =" undefined ") {alert (" select a decision maker! "); Return ;}
Else if (rowid> 0 ){
Var url = "savedemo-. action? "+ GetParams ();
// Document. write (url );
Alert (url );
/***/
$. Ajax ({
Url: url,
Type: 'post ',
DataType: 'json ',
Success: function (json ){
// Reference: http://blog.csdn.net/jpr1990/article/details/6931027
Alert (json );
Window. close ();
},
Error: function (){
Alert ('data loading failed, please try again ..');
// Window. close ();
}
});
} Else {
Alert ("select a recommended solution"); return;
}
} </Span>
Code related to the background Action class (mainly to see how to return JSON data ):
[Java]
<Span style = "font-family: Microsoft YaHei; font-size: 13px;"> /**
* Save decision information
*
0-not started.
1-pause.
2-running.
3-failed.
4-termination.
5-complete.
6-deleted.
*/
Public String save (){
If (includemo! = Null ){
Try {
// Generate the actual decision time
Timestamp decision_date = new Timestamp (System. currentTimeMillis (); // It cannot be later than the force decision time and no judgment has been made
Includemo-. setDecisionMaker (includemo-. getDecisionMaker ());
Includecision. setDecisionTime (decision_date );
// Determine whether the process is automatically started
If (this. getIsStartProcess (). equals ("true ")){
Includemo-. setSolutionState (2); // set SolutionState to: 2-running
This. decisionExecutorService. saveassistdemo-( includemo-, true, processId, emgencyInfoProcessId );
} Else {
Includemo-. setSolutionState (0); // set SolutionState to: 0-not started
This. decisionExecutorService. saveassistdemo-( includemo-, false, processId, emgencyInfoProcessId );
}
JsonMassage = "decision successful, data saved! ";
} Catch (Exception e ){
E. printStackTrace ();
JsonMassage = "there are no default jobs under this process scheme. Please carefully check this process scheme ";
System. out. println (jsonMassage );
Return SUCCESS;
}
}
Return SUCCESS;
} </Span>
Directly print System. out. println (jsonMassage); then return SUCCESS; then jsonMassage data can be returned to the success method on the page:
[Javascript]
<Span style = "font-family: Microsoft YaHei; font-size: 13px;"> success: function (json ){
// Reference: http://blog.csdn.net/jpr1990/article/details/6931027
Alert (json );
Window. close ();
},
Error: function (){
Alert ('data loading failed, please try again ..');
// Window. close ();
}
</Span>
From Hurry's column