Copy codeThe 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 ("<font color = 'red'>" + data. message + "</font> ");
});
});
// 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 ("<div> <font color = 'red'>" + data. message + "</font> </div> ")
},
Error: function (){
$ ("# Message2 "). append ("<div> <font color = 'red'>" + "Information error" + "</font> </div> ")
}
});
});
});