0
視圖工作:
<a onlick="getMembershipDetails('@memberships.OrderTemplateId', '@Url.Action("GetMembershipContractDetails","MembersA")');" class="cw-grid-link">Details</a><br/>
JavaScript函數:
function getMembershipDetails(orderTemplateId, url) {
$.ajax({
type: "GET",
url: url,
data:{
orderTemplateId: orderTemplateId
},
success: function (html) {
//$("#search-structure-target").html(html);
console.log(JSON.stringify(html))
},
error: function (err) {
console.log(err);
},
traditional: true
});
}
控制方法,它應該被稱爲:
public ActionResult GetMembershipContractDetails(string orderTemplateId)
{
if (String.IsNullOrEmpty(orderTemplateId))
return null;
var details = userOrganisationProvider.GetOrgFinSupportDetail(SelectedOrganisation, orderTemplateId);
return Json(details, JsonRequestBehavior.AllowGet);
}
對於s因爲我的JavaScript函數上面沒有被調用。除此之外,所有其他類似的函數都可以被調用。我究竟做錯了什麼?
轉義字符串在你的HTML。 –
'onlick'輸入錯誤? – Caramiriel
onlick should obc onclick – Emil