0

I am new to AJAX and JSON. I have an ArrayList which contains another ArrayList and I converted the whole array in to JSON object:

@Produces(MediaType.APPLICATION_JSON)
public String getRecords(@QueryParam("mobile_no") String mobilenumber) {
    UserActivityDelegate delegate = new UserActivityDelegate();
    List<AssessmentDTO> list = delegate.getLastFiveAssessment(mobilenumber
            .trim());
    if (list.isEmpty())
        return "Sorry....You have not attended any assessment";
    else {
        System.out.println(list);
        return (new Gson()).toJson(list);

    }

Now I want to know how can I retrieve or iterate the response object in JSP using ajax??

1

1 Answer 1

0

In Ajax response you receive a response string you can convert that either to javascript list or json and iterate over them.

Like below:

jQuery.ajax({

              type: 'POST',
              url: your_url_string,
              data: 1=1 //params,
              async: false,
              success: function(response,textStatus){

                json= JSON.parse(response);
             },
                  error:function(XMLHttpRequest,textStatus,errorThrown){}
             });

then json object is what you need to take care of.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.