Reputation: 9767
I am trying to get an Ajax call to my controller and pass back a string... for some reason, I am unable to get down into my controller... Not sure what I am missing...
$.ajax({
url: dummyURL,
success: function (result) {
$('#resultDiv').append('<b>' + result + '</b>');
setTimeout(function () {
window.location = RedirectUrl;
}, 1000);
}
});
This is how I set up my url string:
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);
This is the Action method that I am attempting to call...
public string AddFoundPatient(string FirstName, string LastName, string DOB, string MRN, string EMPIID, int popID)
This is the query string that I generate...
/AddFoundPatient/AddPatient?FirstName=BETTY &LastName=WHITE &DOB=1925-10-25 &MRN=840108105 &EMPIID=11011833 &popID=2
I never hit the debbugging statements inside my action... What am I doing wrong?
Upvotes: 0
Views: 347
Reputation: 2121
The controller and action are mixed up
var dummyURL = '@Url.Action("AddFoundPatient", "AddPatient", new { FirstName = "-1", LastName = "-2", DOB = "-3", MRN = "-4", EMPIID = "-5", popID = (int)TempData["POPULATIONID"] })';
Upvotes: 3