我正在通过Ajax接收Json数据,但是问题是我无法将数据显示到输入Text中,并且一切正常,任何人都可以帮忙
<script type="text/javascript">
function getProblemById(Id) {
var Id = Id;
$.ajax({
url: "/BarnoProblems/getById?Id=" + Id,
type: "GET",
dataType: "json",
success: function (data) {
$('#Discrptions').val( data.Discrption);//here is the problem
},
error: function () {
alert("erorr");
}
});
}
</script>
public JsonResult getById(int Id){
var pro = from pr in db.BarnoProblems
join br in db.Branches
on pr.BranchId equals br.Id
where pr.Id == Id
select new
{
pr.Id,
pr.Discrption,
pr.ProblemImage,
pr.ProblemType,
pr.Source,
pr.statute,
pr.comment,
barnchname = br.Name,
citys = pr.Branch.City.Name
};
return Json(pro.ToList(), JsonRequestBehavior.AllowGet);
}
答案 0 :(得分:0)
在没有看到所有代码的情况下,我假设挂断的是处理数据的方式。它应该看起来像这样:
data['Discrption']
答案 1 :(得分:0)
尝试一下:
success: function(data){
if(data.length > 0)
$('#Discrptions').val(data[0].Discrption);
}