0

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

2
  • is your loadId valid, did you try doing console.log(loadId); before $.get() method...? Commented Mar 19, 2012 at 5:58
  • yes loadId is getting passed correctly before the $.get() method Commented Mar 19, 2012 at 6:00

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.