我正在尝试向我的控制器发送一个Ajax调用并传回一个字符串......出于某种原因,我无法进入我的控制器...... 不确定我错过了什么......
$.ajax({
url: dummyURL,
success: function (result) {
$('#resultDiv').append('<b>' + result + '</b>');
setTimeout(function () {
window.location = RedirectUrl;
}, 1000);
}
});
这是我设置我的网址字符串的方式:
var dummyURL = '@Url.Action("AddPatient", "AddFoundPatient", new { FirstName = "-1", LastName = "-2", DOB = "-3", MRN = "-4", EMPIID = "-5", popID = (int)TempData["POPULATIONID"] })';
var FName = rowData['First_Name'];
var LName = rowData['Last_Name'];
var DOB = rowData['DOB'];
var MRN = rowData['medipacId'];
var EMPIID = rowData['EMPIID'];
//Add Patient call
var path = dummyURL.replace("-1", FName);
path = path.replace("-2", LName);
path = path.replace("-3", DOB);
path = path.replace("-4", MRN);
path = path.replace("-5", EMPIID);
这是我试图调用的Action方法......
public string AddFoundPatient(string FirstName, string LastName, string DOB, string MRN, string EMPIID, int popID)
这是我生成的查询字符串......
/AddFoundPatient/AddPatient?FirstName=BETTY &LastName=WHITE &DOB=1925-10-25 &MRN=840108105 &EMPIID=11011833 &popID=2
我从未在我的行动中发表过侮辱性言论......我做错了什么?
答案 0 :(得分:3)
控制器和操作混合
var dummyURL = '@Url.Action("AddFoundPatient", "AddPatient", new { FirstName = "-1", LastName = "-2", DOB = "-3", MRN = "-4", EMPIID = "-5", popID = (int)TempData["POPULATIONID"] })';