0

This works fine, but consists hardcode in "url" section:

<script type="text/javascript">
    function aj() {
        var a = $('#price').val();
        $.ajax({
            url: "/Item/GetStatus?price=" + a,
            type: this.method,
            success: function (result) {
                $('#w').html(result);
            }
        });
        return false;
    }
</script>

This doesn't consist hadrcode, but it is not clear how to pass variable "a".

<script type="text/javascript">
    function aj() {
        var a = $('#price').val();
        $.ajax({
            url: "@Url.RouteUrl(new {controller = "Item", 
                                     action = "Getstatus", 
                                     price = "a"})",
            type: this.method,
            success: function (result) {
                $('#w').html(result);
            }
        });
        return false;
    }
</script>

Using variable is not necessary. How can I pass variable? Maybe I use incorrect helper, or overload?

1 Answer 1

2

You could ofcourse just do

url: "@Url.RouteUrl(new {controller = "Item", action = "Getstatus"})?price=" + a,
Sign up to request clarification or add additional context in comments.

1 Comment

just add please "}" where you missed it.

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.