success: function (data ,textStatus, jqXHR) { var datas = eval(data);//将msg化为数组 var num = 1; $.each(datas, function (num) { //alert(data[num].userName); var id = datas[num].id;//注意要与实体类中的名称相同 var Name = datas[num].name; var publicHouse = datas[num].publicHouse; var publicDate = datas[num].publicDate; var author = datas[num].author; var description = datas[num].description; var price = datas[num].price; alert(id,Name,publicDate,publicHouse,author,description,price); var value = "<tr><td align='center'><input name='checked' type='checkbox' value=" + id + "/></td><td align='center'>" + Name + "</td> <td align='center'>" + Name + "</td> <td align='center'>" + publicHouse + "</td> <td align='center'>" + publicDate + "</td><tr/>"; //value += "<td align='center'>" + Name + "</td> <td align='center'>" + Name + "</td> <td align='center'>" + publicHouse + "</td> <td align='center'>" + publicDate + "</td><tr/>"; $("#tb").append(value);//写入到id为tb的html部分 }); }, /*success:function(data){ alert("hello"); var json = eval("("+data+")"); //var json=JSON.parse(data); alert(json); for(var js2 in json){ alert( js2+"="+json[js2]); } },*/ error:function (XMLHttpRequest, textStatus, errorThrown) { alert("请求失败!"); } }); } </script> <table id="tb" width="80%" border="1" cellspacing="0" cellpadding="0" align="center" > <tr> <%-- <th align="center"><input name="checked" type="checkbox" /></th>--%> <th align="center">ID</th> <th align="center">Name</th> <th align="center">Password</th> <th align="center">Phone</th> <th align="center">Address</th> </tr> </table>
获取数据后插入到jsp页面(自用,没内容)
最新推荐文章于 2021-02-23 16:31:30 发布