0
因此,我正在通過AJAX做一個GET控制器方法來返回一些JSON。 返回JSON是好的,但發送參數來構造一個簡單的對象不會 - 結果作爲該對象的默認值!發送JSON問題 - 似乎沒有正確發送
有什麼想法?
模型:
public class CoreViewModel
{
public int Id {get; set;}
public int ExtensionId {get;set;}
public string Zip {get; set;}
public int ShopId {get; set;}
}
控制器:
public ActionResult GetDetails(CoreViewModel model)
{
return Json(new DetailsViewModel(model), JsonRequestBehavior.AllowGet);
}
AJAX:
$.ajax({
type: "GET",
url: serviceUrl + "GetDetails/",
contentType: "application/json; charset=utf-8",
crossDomain: false,
cache: false,
dataType: 'json',
data: '{"Zip":"@Model.Zip","ShopId":@Model.ShopId,"ExtensionId":@Model.ExtensionId,"Id":@Model.Id}',
success: function(data) {
};
},
.. ..