0

i have this method in spring controller which returns hash map.

@RequestMapping(value = "/CIMtrek_Project_Information", method = RequestMethod.POST)
    public @ResponseBody Map<String,String> getProjectInfotmation(@RequestParam("cerNo") String cerNo,HttpServletRequest request,HttpServletResponse response) throws Exception {
        DataService ds = new DataService();
        Map<String,String> projectInforamtionMap = new HashMap<String,String>();
        projectInforamtionMap = ds.getProjectInformation(cerNo);
        System.out.println("projectInforamtion : "+projectInforamtionMap);
        return projectInforamtionMap;
    }

and this the jquery ajax method i used :

function getProjectInformation(){
    var cerNo = document.getElementById('CIMtrek_CI_CER').value;
     $.ajax({
         type: "POST",
         url: "CIMtrek_Project_Information",
         data: {
             cerNo: cerNo
         },
         success: function (projectInforamtionMap) {
             if(projectInforamtionMap.norecord !="yes"){
                 document.getElementById('projectNo').innerHTML=projectInforamtionMap.CI_Used_By_ProjNo;
                 document.getElementById('CIMtrek_CI_Used_By_ProjNo').value=projectInforamtionMap.CI_Used_By_ProjNo;

                 document.getElementById('projectName').innerHTML=projectInforamtionMap.CI_Used_By_ProjName;
                 document.getElementById('CIMtrek_CI_Used_By_ProjName').value=projectInforamtionMap.CI_Used_By_ProjName;

                 document.getElementById('projectManager').innerHTML=projectInforamtionMap.CI_Used_By_ProjMgr;
                 document.getElementById('CIMtrek_CI_Used_By_ProjMgr').value=projectInforamtionMap.CI_Used_By_ProjMgr;

                 document.getElementById('projectStatus').innerHTML=projectInforamtionMap.CI_Used_By_Status;
                 document.getElementById('CIMtrek_CI_Used_By_Status').value=projectInforamtionMap.CI_Used_By_Status;

                 document.getElementById('projectBDM').innerHTML=projectInforamtionMap.CI_Used_By_BDM;
                 document.getElementById('CIMtrek_CI_Used_By_BDM').value=projectInforamtionMap.CI_Used_By_BDM;

                 document.getElementById('projectITPlan').innerHTML=projectInforamtionMap.CI_Used_By_IT_Plan;
                 document.getElementById('CIMtrek_CI_Used_By_IT_Plan').value=projectInforamtionMap.CI_Used_By_IT_Plan;

                 document.getElementById('projectBucket').innerHTML=projectInforamtionMap.CI_Used_By_IT_Bucket;
                 document.getElementById('CIMtrek_CI_Used_By_IT_Bucket').value=projectInforamtionMap.CI_Used_By_IT_Bucket;
             }

         }
     });
}

but i get this response during callback;

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.

Please help me to resolve this.

Best Regards.

1 Answer 1

1

Try this

Change

 projectInforamtionMap = ds.getProjectInformation(cerNo);

to

projectInforamtionMap.put("projectInforamtionMap", ds.getProjectInformation(cerNo));

In your ajax call add

contentType: 'application/json',

and

dataType : 'json',
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.