Why does my submit button fail to trigger Javascript MVC?

Posted by user54197 on Stack Overflow See other posts from Stack Overflow or by user54197
Published on 2010-04-29T14:12:07Z Indexed on 2010/04/29 14:17 UTC
Read the original article Hit count: 259

Filed under:
|
|
|

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>

© Stack Overflow or respective owner

Related posts about html

Related posts about c#