Why does my submit button fail to trigger Javascript MVC?
- by user54197
I have a simple code from a book and the code should display data from my controller in the "results" span. What am I missing?
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
$("form[action$='GetQuote']").submit(function() {
$.post($(this).attr("action"), $(this).serialize(), function(response) {
$("#results").html(response);
});
return false;
});
</script>
<h2>Index</h2>
<%using (Html.BeginForm("GetQuote","Stocks")) { %>
Symbol:
<%= Html.TextBox("symbol") %>
<input type="submit" />
<span id="results"></span>
<% } %>
<p><i><%=DateTime.Now.ToLongTimeString() %></i></p>
</asp:Content>