Loading JSP on AJAX call in LIferay

1.1k Views Asked by At

I have a jsp page which is loaded on the click of a link, and a AJAX call is made which updates my model attritube, the problem I am facing is when I try to load my JSP thorugh AJAX, JSON data is printed on the page instead, I want to display JSP with updated values.Can somebody help ?

JS Code :

       $.ajax({
       url : resourceUrlStoredInVariable,
       dataType : "json",
       type: 'POST',
       contentType: 'application/json',
       data : {
          UserId : $(SELECTOR.UserID).val()
              },
          success : function(data) {

          $("#Container").load(resourceUrlStoredInVariable);
             }
           }).fail(function() {
            alert("Error..");

           });

Server Code: @ResourceMapping("resourceHandlerId")

@ResponseBody
public void getStudentInfo(ResourceRequest request, ResourceResponse response, Model model)
        throws JsonGenerationException, JsonMappingException, IOException, PortletException {
    StudentInfo studentInfo= (StudentInfo) model.asMap().get(
            "studentInfo");
    facade.populateStudentInfo(studentInfo);

    response.setContentType("application/json");
    ObjectMapper mapper = new ObjectMapper();
    mapper.writeValue(response.getPortletOutputStream(), studentInfo);
} 
0

There are 0 best solutions below