Ajax没有从服务器获得json响应

时间:2017-09-13 12:46:42

标签: java jquery ajax jersey-2.0

我是jquery / Ajax的新手。 我的服务器代码返回json数据 但它没有在jquery / ajax中收到。 我试过的 这是我的ajax请求代码

$.ajax({
        type: 'post',
        url:'http://localhost:8080/eduvib/webapi/question/getPaper', 
        dataType:'json',
        data: {"subject":subject,"cls":classes,"diff":dificultylevel,"marks":marks},
        success:function(response) {
            alert(JSON.stringify(response));

        },
        error:function() {
             alert("request failed");
        }                 
    });

这是我的服务器端代码,也返回响应

@POST
@Path("/getPaper")
@Consumes({MediaType.APPLICATION_FORM_URLENCODED,MediaType.APPLICATION_JSON})
@Produces(MediaType.APPLICATION_JSON)

public List<Question> getPaper(@FormParam("subject") String subject, @FormParam("cls") String cls,
        @FormParam("diff") int diff, @FormParam("marks") int marks) throws Exception {

    ArrayList<Question> mylist = new ArrayList<Question>();
     mylist = getQuestionList.getData(subject, cls, diff, marks);
     System.out.println(mylist);
     return mylist;

}

这是服务器端的日志,它在命中ajax请求后打印响应

   [Question [questionid=questionid, questiontext=kk, topicname=k,...... complete list

但是在Ajax请求它没有得到

0 个答案:

没有答案