views:

26

answers:

2
public JsonResult UnassToOrder(string location, string article_number)
    {
        //....

        return Json(new {

            success = true,
            redirect = "ImportXML/Index"

        });
    }



<script type="text/javascript">
$(document).ready(function() {

    $('input:radio').click(function() {

        var location = $("input:checked").val();
        var article_number = $("input[id=MArticleNumber]").val();

        $.post("/SomeController/SomeAction", { location: location, article_number: article_number }, function(data) {


                window.location.href = data.redirect;

        },"json");
    });
});
</script>

I have 3 radio buttons. When click on first one I have redirect to "ImportXML/Index" with this line of code: window.location.href = data.redirect;. When I click on second radio button my URL on browser is "ImportXML/ImportXML/Index" and this is error because correct URL is "ImportXML/Index"

+1  A: 

You can absolutize your path like this:

window.location.href = "/" + data.redirect;
floatless
+1  A: 

I would highly recommend using the UrlHelper class to build your URLs.

return Json(new {
        success = true,
        redirect = Url.Action( "Index", "ImportXML ")
    });
dave thieben