숫자가 있습니다. 내가 사용하지 않고 다른 페이지로이 값을 전달하는 데 필요한 window.location
URL을 사용하지 않고 매개 변수를 전달하는 방법
function sample(cID){
var clg = ${param.clg};
$.ajax({
type : "post",
url : "sampleShow?clg="+clg+"&cID="+cID+"&level="+level,
dataType : "json",
cache : false,
beforeSend : function(xhr) {
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
},
success : function(response) {
window.location= "cc"
},
error : function(xhr) {
console.log("error"+xhr.status);
},
complete : function() {
}
});
}
이 내 컨트롤러 아약스 기능입니다 : 내가 CC 페이지에서 값을 얻을 필요가
@RequestMapping(value = "sampleShow", method = RequestMethod.POST)
public @ResponseBody
String showc(HttpServletRequest request,Model model)
{
model.addAttribute("ccID", request.getParameter("cID"));
model.addAttribute("clg", request.getParameter("clg"));
model.addAttribute("level", request.getParameter("level"));
return "{\"sucess\":\"true\"}";
}
.
왜 dataType : "json"을 설정 했습니까? json 데이터를 보내시겠습니까, 아니면 그냥 문자열 데이터입니까? –
@sudarshan_SMD 그냥 문자열 데이터 – VSN