Asynchronous data loading is implemented using struts2 + jquery + json. The specific code is as follows. For more information, see.
The Code is as follows:
// When the page is initially loaded
$ (Document). ready (function (){
// Register the mouse-click event for the button that gets a single value
$ ("# GetMessage"). click (function (){
$. GetJSON ("ceshi", function (data ){
// The. operator can be used to obtain the value of message in Action from data. message.
$ ("# Message1" 2.16.html ("" + data. message + "");
});
});
// Send expression data to the server
$ ("# Getabc"). click (function (){
// Serialize the form data
Var params = $ ("form"). serialize ();
// Use the $. ajax ({}); Ajax method in jQuery
$. Ajax ({
Url: "ceshi ",
Type: "POST ",
Data: params,
DataType: "json ",
Success: function (data ){
// Add the obtained data to the display Layer
// Use data. userInfo. To obtain object data
$ ("# Message2"). append ("
"+ Data. message +"
")
},
Error: function (){
$ ("# Message2"). append ("
"+" Error message "+"
")
}
});
});
});