填充视图页面我在我的Site.Master应基于在同一个页面从下拉菜单中选择的项目进行popultating我的文本框下面的脚本。使用JSON对象
$(function() {
$("#vendorID").change(function() {
var selectedItem = $(this).val();
if(selectedItem != "New Vendor Id")
{
$.getJSON(
"<%=Url.Action("DropDownChange") %>/?dropdownValue=" + selectedItem,
function(data) {
//$("#Data").html(data);
$("#name").val(data.Name);
}
);
$(document).ready(function() {
$("#zip").val('');
});
,我没有得到任何错误,我没有得到填充文本框......这可能是我的可能出现的错误????
ASP.NET代码;
公共JsonResult DropDownChange(串dropdownValue) //此操作方法被通过Ajax请求
{ // dropdownValue = “FR28406” 调用;
if (dropdownValue != null && Request.IsAjaxRequest() == true)
{
paymentApplicationRefund =
cPaymentRepository.PayableEntity(dropdownValue);
paymentApplicationRefund.Address1.Trim();
paymentApplicationRefund.Address2.Trim();
paymentApplicationRefund.Name.Trim();
paymentApplicationRefund.City.Trim();
paymentApplicationRefund.Contact.Trim();
paymentApplicationRefund.State.Trim();
paymentApplicationRefund.Zip.Trim();
return Json(paymentApplicationRefund,"application/json");
}
else
{
return null;
}
}
我没有得到一个错误 - 500内部服务器错误。我打算发布我的ASP.NET代码。 – JamaicasFinest 2011-03-08 18:13:41
那么我的ASP.NET代码出错了? – JamaicasFinest 2011-03-08 18:19:09
如果我不得不猜测,那是你的其中一个属性为null,当你调用“.Trim()”时会抛出一个错误。真的,你不需要修剪那么多,这些错误可以通过调试很容易地发现。 – 2011-04-06 15:31:19