Ok so the situation is that I am on my index page. I have a jQuery onClick event as follows:
$('#example').on('click', 'tr', function (e) {
var aData = oTable.fnGetData(this);
showCampaign(aData);
});
I have verified that this function is working as intended and aData winds up populated with an array containing the data from each cell in the table row that gets clicked.
What i need to do is when this click even occurs shoot aData to my MVC and load a new view that i can populate with that data. This is what im currently trying....
function showCampaign(aData) {
$.ajax({
type: "POST" ,
url: "Test/Show",
data : aData
}).done(function (response) {
window.location.href = response.Url;
}).error(function (jqxhr, textstatus, errorthrown) {
alert("didn't work");
});
};
This function works to a point ... it does send a request to my MVC ... but I am not seeing the data come through (its null) and when I return the response string the page does not load.
The method in my Controller class looks like this :
[HttpPost]
public ActionResult ShowCampaign(String[] aData)
{
var redirectUrl = new UrlHelper(Request.RequestContext).Action("TestView","Test");
return Json(new {Url : redirectUrl });
}
For purposes of the above TestView is the name of the View i want to load and Test is the Controller.
What am I doing wrong here.. Im trying to understand MVC but I just dont get it yet ... the light hasnt clicked on.