Reputation: 3
I have jquery function which looks like this
function MonitorLoadStatus(loadId) {
var url = 'LoadAdmin/GetLoadStatus/' + loadId;
$.get(url, function (data) {
if (data != "complete") {
$("img[id =" + loadId + "]").show();
window.setTimeout(function () {
MonitorLoadStatus(loadId);
}, 1000);
}
else {
$("img[id =" + loadId + "]").hide();
};
});
}
and an MVC method which looks like this
public ActionResult GetLoadStatus(string loadId)
{
// check some thing and return stuff
return Content(currentProgress);
}
The loadid to the above method is being passed as null from the jquery get method. What exactly am i doing wrong
Upvotes: 0
Views: 1132
Reputation: 1039458
Make sure you have a route in your Global.asax which has a /{loadId}
at the end. I remind you that the default route looks like this:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
meaning that the parameter should be called id
in your controller action:
public ActionResult GetLoadStatus(string id)
{
// check some thing and return stuff
return Content(currentProgress);
}
If you want to use loadId
update your route definitions accordingly.
Upvotes: 1