을 수락하지 그러나MVC JsonResult 방법 나는 하나 개의 문자열 매개 변수를 받아들이는 MVC JsonResult 방법이 매개 변수
//Fetch Destinations
$("#Country").change(function() {
var countryId = $("#Country > option:selected").attr("value");
$("#Destination").html("");
$("#Resort").html("");
$("#Resort").append($("<option></option>").val(0).html("---Select---"));
$.ajax({
type: "POST",
traditional: true,
url: "/Destinations/GetDestinations",
data: "{countryId:'" + countryId + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
BindDestinationSelect(msg)
}
});
});
을의 JsonResult는 만에 보인다 널 (NULL) 매개 변수를 수신하십시오. 방화범이 매개 변수가 전달되고 있음을 보여주고있다하더라도 :
JSON 이 "11" 소스 을 countryId {countryId : '11 '}
어떤 아이디어가? 감사합니다
FWIW,' "{countryId : '"+ countryId + "'}"'는 JSON이 아닙니다. JSON에는 큰 따옴표가 필요합니다. Firebug에서 POST 요청을 볼 때 http://www.json.org/json2.js와 같은 객체를 사용하여 객체를 JSON 형식 – R0MANARMY