0
我正在使用MVC4控制器返回值到ajax函數來做一些事情在客戶端。不幸的是,返回值沒有綁定到ajax方法。請幫幫我。jquery ajax函數不綁定返回結果
我的ajax方法;
$.ajax({
type: 'GET',
url: '/Service/Utility/GetcustomerAddressProofByCustomerId',
data: { customerId: customerId },
success: function (rtnResult) {
if (rtnResult.Result.lenght > 0) {
alert("ok");
}
else {
alert("no");
}
}
});
控制器方法;
public ActionResult GetcustomerAddressProofByCustomerId(int customerId)
{
List<CustomerSecondaryID> items = db.CustomerSecondaryID.Where(a => a.customerId == customerId).ToList();
return Json(items , JsonRequestBehavior.AllowGet);
}
請幫我做到這一點。
dataType:'json''在哪裏? – webdeveloper
就像一個提示(我每天使用),你可以寫「console.log(rtnResult);」 +任何體面的瀏覽器,我會建議鉻,看看結果的格式,以協助您調試您的JavaScript。 –
是的。它的JSON,但它也會提醒(「否」) – user2710638