SoftwareSavant
SoftwareSavant

Reputation: 9767

.ajax call not getting to my controller... Not sure why

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 &amp;LastName=WHITE &amp;DOB=1925-10-25 &amp;MRN=840108105 &amp;EMPIID=11011833 &amp;popID=2

I never hit the debbugging statements inside my action... What am I doing wrong?

Upvotes: 0

Views: 347

Answers (1)

Paolo del Mundo
Paolo del Mundo

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

Related Questions