Html Form: Bind to submit event

Search for the form that action name ends with: 'GetQuoteJsonP'.
        $("form[action$='GetQuoteJsonP']").submit(function () {
            $.ajax({
                url: $(this).attr("action"),
                data: $(this).serialize(),
                dataType: "jsonp",
                success: function (stockData) {
                    $("#openingPrice").html(stockData.OpeningPrice);
                    $("#closingPrice").html(stockData.ClosingPrice);
                    $("#stockRating").html(stockData.Rating);
                }
            });
            return false;
        });
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s