0

I am getting parse Error

Ajax

$.ajax({
                    type: "POST",
                    url: "getStagingImrReport.do",
                    data: dataString,
                    dataType: "JSON", 
                    //if received a response from the server
                    success: function( data, textStatus, jqXHR) {  //our country code was correct so we have some information to display  
                        alert(data);
                      //$("#ajaxResponse").html("<div><b>Country code in Invalid!</b></div>"); 
                    }, 
                    //If there was no resonse from the server
                    error: function(jqXHR, textStatus, errorThrown){
                        alert("Something really bad happened " + textStatus);
                          //$("#ajaxResponse").html(jqXHR.responseText);
                    }, 
                    //capture the request before it was sent to server
                    beforeSend: function(jqXHR, settings){
                        //adding some Dummy data to the request
                        settings.data += "&dummyData=whatever";
                        //disable the button until we get the response
                        $('#myButton').attr("disabled", true);
                    }, 
                    //this is called after the response or error functions are finsihed
                    //so that we can take some action
                    complete: function(jqXHR, textStatus){
                        //enable the button 
                        $('#myButton').attr("disabled", false);
                    } 
                }); 

controller

public void getStagingImrReport(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        try {
            // String policyType = request.getParameter("policyType");
            List<String> drop = new ArrayList<String>();
            response.setContentType("application/json");
            response.setHeader("Cache-Control", "no-cache");
            response.setHeader("Pragma", "no-cache");
            final ILoadMgr iLoadMgrRef = (ILoadMgr) getContext().getBean(
                    IConstants.LOAD); 
            List<PTypeVO> listVO = iLoadMgrRef
                    .getPolicyTypes(IConstants.MFFILTER);
            for (PTypeVOpolicy : listVO) {
                drop.add(policy.getPolicyTypeName()); 
            }
            JSONObject jsonObject=new JSONObject();
            jsonObject.put("jsonVal", drop);
            PrintWriter out = response.getWriter(); 
            System.out.println(" XXXX--------"+drop);

            out.println(drop); 
            out.flush();
        } catch (Exception exp) {
            Logging.error(
                    "[LoadController.getpolTypesAjaxDropdown] Exception occured ",
                    exp);
        }
    }

Output on console for sysOut

 //----XXXX--------[CHIP, County Health Program, Disability, Discount Card, Imputed, Indian Tribe, Mail Order, Medicaid MCO, No Coverage, Other, Rehabilitation, State]

and Jquery alert message shows:

"something really bad happened parse error"
1

1 Answer 1

0

your return type is NOT JSON..its a list or array of string, change your data type or change your return type

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.