I have something like this
<button onclick="JavascriptFunction();">HTTPPost Button</button>
<script type="text/javascript" language="javascript">
function JavascriptFunction() {
var url = '@Url.Action("PostMethod")';
var data = $('input[name="MyTextBlock"]').serialize();
$("#divLoading").show();
$.post(url, data,
function (data) {
$("#PID")[0].innerHTML = data;
$("#divLoading").hide();
});
}
</script>
in which I want to pass in multiple controls (including textboxes and dropdowns) how can I add that into var data? Thanks. I should also mention that MyTextBlock is a TextBox.
On this line,
you can include all of the elements you want to serialize into the query string. For example, if your dropdown had the id
dropdown, you could do this: