After Ajax traverses jSon, it modifies and deletes each piece of data (code sharing). ajaxjson
If you don't talk much about it, paste the Code directly. The specific code is as follows:
$. Ajax ({url: "/business/findpersons. json ", dataType:" json ", type:" GET ", success: function (doc) {var objs = eval (doc); for (var I = 0; I <objs. length; I ++) {var personid = objs [I]. personId; var name = objs [I]. personName; var email = objs [I]. personEmail; var sector = objs [I]. personSector; var position = objs [I]. personPosition; var password = objs [I]. personPassword; $ ("# personList thead "). append ("<tr>" + "<th>" + name + "</th>" + "<Th>" + password + "</th>" + "<th>" + email + "</th>" + "<th>" + position + "< /th> "+" <th> <input type = 'button 'value = 'delete' name = "+ I +" class = 'deleteersonbut'> </th> "+ "<th> <input type = 'button 'value = 'modify 'name =" + I + "class = 'updatapersonbut'> </th>" + "</tr> "); var getA = "# personList. deletePersonBut [name = "+ I +"] "; // the reason for this, That I = objs. the cause of length should be the closure. $ (GetA ). click (function () {var thid = $ (this ). parent (); var pid = thid. children (". deletePersonBut "). attr ('name'); alert (objs [pid]. personId) ;}); var getA = "# personList. updataPersonBut [name = "+ I +"] "; // the reason for this, That I = objs. the cause of length should be the closure. $ (GetA ). click (function () {var thid = $ (this ). parent (); var pid = thid. children (". updataPersonBut "). attr ('name'); alert (objs [pid]. personId );});}}});
The above section describes how to modify and delete each piece of data after Ajax traversal of jSon. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!