ajax parseerror 调试,ajax请求springMVC 返回json数据 老是parseError??

冷翼
2023-12-01

1

@RequestMapping("/deptLevel")

public String deptLevel(Model model,@RequestParam(value="deptId",required=false) String deptId,HttpServletResponse response){

List deptInfoLevelList = deptService.selectDeptIdByDeptLevel(Integer.parseInt(deptId));

JSONObject jsonObject = new JSONObject();

jsonObject.put("list",1);

String str = "{\"myvalue\":\"red\"}";

try {

response.getWriter().write(jsonObject.toString());

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return "insertHouseSkip";

}

2.

$.ajax({

type: "POST",

url: "server/house/deptLevel.do",

data: {deptId:$("#houseUnit").val()},

dataType:"json",

success: function(data){

alert(data);

},

error: function(XMLHttpRequest, textStatus, errorThrown) {

alert(XMLHttpRequest.status);

alert(XMLHttpRequest.readyState);

alert(textStatus);

}

});

}

实在不明白了

 类似资料: