getJSON not working if the mvc model view controller has a parameter

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2010-02-27T12:41:04Z Indexed on 2010/04/28 4:23 UTC
Read the original article Hit count: 1246

Filed under:
|
|
|

I'm having an issue with a callback. I'm not even getting an error in Firebug. If I alert before and after the getjson call both alerts show but the getjson call doesn't fire.

public ActionResult TestPage()
    {

        return View();
    }

public ActionResult LoadMapLonLats(int mapId)
    {
        //some code
        return Json(_myMaps);
    }


$("#Search").click(function() {
        $.getJSON("LoadMapLonLats", { mapId: 73 }, loadDbMap);
    });

    function loadDbMap(maps) {
        alert('m');
        $.each(maps, function(i) {
            alert(maps[i]);
        });
    }

As long as I leave TestPage without a parameter is works. If I add a parameter to TestPage(int id) then the call back to LoadMapLonLats doesn't work. Seems odd. Of course TestPage is the page I'm loading so I need to do some work here before rendering the page. Not sure why adding a parameter to the view would break the callback to another function.

//this breaks he callback to LoadMapLonLats

public ActionResult TestPage(int id)
    {

        return View();
    }

Any ideas? Seems like this may be related, if not sorry I can post a new thread.

© Stack Overflow or respective owner

Related posts about getjson

Related posts about mvc