Their are many examples on google but they are not helpful, i'm getting this error VM169:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse ()
here 0 is GET and POST 1 is Json in jquery file
$("#stateID").change(function(){
var stateID= $(this).val();
if(stateID != ""){
var stateJson=xAjaxCall("ajax/state-city-json/"+stateID,null,0,1);
if(stateJson != null && !xIsEmptyJSON(stateJson)){
xBindJSONtoCombo(stateJson, $("#cityID"));
}
}
});
My controller
@ResponseBody //get State-city-json
@RequestMapping(value="/ajax/state-city-json/{stateID}",method = RequestMethod.GET)
public String getStateJson(@PathVariable("stateID") int stateID){
System.out.println("Ajax call city");
return JSONObject.toJSONString(userRegistrationCommonService.getCityMap(stateID));
}