Is it possible to submit a form with jquery without explicity having to set the data.
ie. I have the following form
<% using (Html.BeginForm("Search", "DrawingWindow", FormMethod.Get, new {id="DrawingSearch"}))
{ %>
<div>
<%: Html.LabelFor( m=> m.DrawingNumberName, new {@class="dark_blue"}) %>
</div>
<div>
<%: Html.TextBoxFor(m=> m.DrawingNumberName)%>
<%: Html.Submit("Search") %>
</div>
<% } %>
and I would like to do something like the following:
$('#drawingSearch').submit(function (e) {
e.preventDefault();
$ajax({
url: '<%:Url.Action("Search", "PID") %>',
type: 'GET',
})
});
Now since I havent specified any data here I think the textbox I have wont be sent in the ajax request, is there a way to include it without having to give the textbox an id and make a data object to send as part of the request?
You can put it inside a form tag, and use the jquery serialize function.
In this way, you can put as many input fields inside the form as you would like, and not have to change the javascript/jQuery code.