我正在尝试使用ajax,但是ajax无法正常工作。所以我提到: https://datatables.net/manual/ajax。
一个数据对象,什么也没得到。
这是我的Javascript代码
$(document).ready(function(){
var table = $('#myTable').DataTable({
ajax: 'notUsed.ad',
columns: [
{"data":'memNum'},
{"data":'memId'},
{"data":'memName'},
{"data":'memGender'},
{"data":'memPhone'},
{"data":'nationCode'},
{"data":'memPoint'},
{"data":'memType'},
{"data":'memStatus'},
{"data":'enrollDate'},
{"data":'noShow'}
]
});
});
和HTML标记:
<table id="myTable" class="table table-bordered display">
<thead>
<tr>
<th>num</th>
<th>id</th>
<th>name</th>
<th>gender</th>
<th>phone</th>
<th>nation</th>
<th>point</th>
<th>type</th>
<th>status</th>
<th>enroll_date</th>
<th>noshow</th>
</tr>
</thead>
</table>
和servlet
public class TableMemSearch extends HttpServlet {
private static final long serialVersionUID = 1L;
public TableMemSearch() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ArrayList<Member> list = new AdminService().searchMember();
JSONArray jArr = new JSONArray();
JSONObject jobj = new JSONObject();
for (Member m : list) {
JSONObject jsonMember = new JSONObject();
jsonMember.put("memNum", String.valueOf(m.getMemNum()));
jsonMember.put("memId", String.valueOf(m.getMemNum()));
jsonMember.put("memName", String.valueOf(m.getMemName()));
jsonMember.put("memGender", String.valueOf(m.getMemGender()));
jsonMember.put("memPhone", String.valueOf(m.getMemPhone()));
jsonMember.put("nationCode", String.valueOf(m.getNationCode()));
jsonMember.put("memPoint", String.valueOf(m.getMemPoint()));
jsonMember.put("memType", String.valueOf(m.getMemType()));
jsonMember.put("memStatus", String.valueOf(m.getMemStatus()));
jsonMember.put("enrollDate",String.valueOf(m.getEnrollDate()) );
jsonMember.put("noShow",String.valueOf( m.getNoShow()));
jArr.add(jsonMember);
}
jobj.put("data", jArr);
response.setContentType("application/json; charset=utf-8");
response.getWriter().print(jobj);
它什么也不返回。
没有错误,没有结果。
我不知道该怎么办。这是结果的屏幕截图,并且在Eclipse中没有错误:
请帮助。8ㅅ8 ...