SamJolly
SamJolly

Reputation: 6477

How to change this JS script to issue a "GET" instead of a "POST" call

I have this script:

        <script type='text/javascript'>
        $('#StdThemePropertyId').change(function () {
            $(this).parents('form').submit();
        });
    </script>

Which calls my MVC Controller to repopulate a child dropdown. The Child Dropdown is a "required" field so is throwing a validation error each time I try to filter it when selecting from the parent dropdown. I believe the answer is to simply alter the above script to issue a "GET" call. However my JS is a little lacking.

How can I alter the above JS to ensure a "GET" call is issued please.

Many thanks.

Upvotes: 0

Views: 72

Answers (2)

Travis J
Travis J

Reputation: 82297

Simply set the form's method to get:

$(this).parents('form').attr('method','get').submit();

Upvotes: 3

mohkhan
mohkhan

Reputation: 12315

put this line before the submit call...

$(this).parents('form').attr("method", "GET");
$(this).parents('form').submit();

Upvotes: 2

Related Questions