The following jquery code can achieve the expected results.
Copy codeThe Code is as follows:
$ (". Derek"). each (function (){
$ (This). click (function (){
Var params = $ (this). parent (). serialize ();
Var obj = $ (this). parent (). siblings ("div # caskContent ");
Var form = $ (this). parent ();
$. Ajax ({
Url: "editCaskContent ",
Type: "post ",
Data: params,
DataType: "json ",
Success: function (e ){
Obj. empty ();
Obj.html ("<font color = \" #00AA00 \ "> question: </font> ");
Obj. append (e. caskContent );
Form. toggle ();
Alert ("modified successfully! ");
},
Error: function (e ){
Alert (e );
}
});
});
});
As you can see, before sending an ajax request, I defined two variables, obj and form, respectively, to store two jquery objects. If $ (this) is used in the ajax callback function, it turns out that no object can be obtained. For specific reasons, I hope you can leave a message ..