MVC控制器方法未從我聲明的ajax中調用。 PFB的代碼片段 C#控制器:未從ajax調用MVC控制器方法
public ActionResult Checkfunction(string ReqID, string AssociateId, string AssetId)
{
MyDetails obj = new MyDetails();
List<string> Lst = new List<string>();
Lst = obj.Check(AssociateId, AssetId, ReqID);
return this.Json(Lst, "text/json");
}
Javascript代碼(AJAX調用):闖民宅細節控制器和的WebMethod Checkfunction
$.ajax({
type: 'GET',
cache: false,
url: '@Url.Action("Details/Checkfunction")',
data: { 'ReqID': RequestId, 'AssociateId': AssociateID, 'AssetId': Host_Name },
contentType: "application/json",
success: function (data) {
debugger;
if (data.length > 0) {
ViewModel.REQUESTID() = data[0];
ViewModel.FLAG() = '1';
}
else {
debugger;
ViewModel.FLAG() = '0';
ViewModel.REQUESTID() = '';
}
if (ViewModel.REQUESTID() != '' || ViewModel.REQUESTID() != null) {
debugger;
ViewModel.REQID() = RequestId;
}
},
error: function (error) {
alert("error");
}
});
Checkfunction是不是在你的ajax調用? – g2000
您的ajax網址指向'PhoenixInbox/CheckMSDNRemap',但您的方法是'Checkfunction'?這將是一個很好的起點 – Jonesopolis
GetUrl()是做什麼的? – ssimeonov