1

I the site is on the following URL localhost:xxxx/VnosPrijavnica/Predmeti/123456, where the VnosPrijavnica is the controller, Predmeti is an action in the controller, and 123456 is an optional param (everything is defined correctly in Global.asax). The site loads fine, just when it comes to jQuery's $.post() I encoutered a problem. The jQuery code looks like this:

$("#predmet").change(function () {
    $("#predmet option[value='prazen']").hide();
    $.post("/VnosPrijavnica/PoisciRoke", $("#kriteriji").serialize(), function (data) {
        $("#roki").html(data);
    });
});

The $.post() never executes. I noticed if I change the URL to localhost:xxxx/VnosPrijavnica this piece of jQuery code works as intended. The question is what must I modify in the jQuery code that it will work with the first URL as it does in the second?

2
  • Try checking your action method names and parameters. Maybe the second URL name that works has the correct method parameters to take the POST request, where as the first one doesn't? I don't think there's anything from a jQuery perspective that's stopping this working. Commented May 9, 2011 at 20:52
  • I think the parameters are ok, as I said if I rework the code and this is called just from localhost/VnosPrijavnica everything works fine. Commented May 9, 2011 at 20:59

1 Answer 1

1

Try something like this:

var baseUrl = '<%= ResolveUrl("~/") %>';

$("#predmet").change(function () {
    $("#predmet option[value='prazen']").hide();
    $.post(baseUrl + "/VnosPrijavnica/PoisciRoke", $("#kriteriji").serialize(), function (data) {
        $("#roki").html(data);
    });
});
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.