Reputation: 1492
I'm implementing a feedback side panel. It is possible tp have more forms on the view, so I have to specify the id of this form. Once I do this, the script is giving me problems.
It says:
Uncaught ReferenceError: $ is not defined
Any ideas?
This is my partial view code.
@model project.FeedbackViewModel
@{
ViewBag.Title = "Feedback";
}
<h2>Feedback</h2>
<div id="result"></div>
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "feedbackform" }))
{
@Html.ValidationSummary()
<p>User:</p>
<p>@Html.TextBoxFor(m => m.UserName, new { @readonly = "readonly" })</p>
<p>Email:</p>
<p>@Html.TextBoxFor(m => m.UserEmail, new { @readonly = "readonly" })</p>
<p>Message:</p>
<p>@Html.TextAreaFor(m => m.Description, new { @cols = 80, @rows = 10 })</p>
<input type="submit" value="Submit" />
}
<script type="text/javascript">
$(function () {
$('#feedbackform').submit(function () {
if ($(this).valid()) {
$.ajax({
url: this.action,
type: this.method,
data: $(this).serialize(),
success: function (result) {
$('#result').html(result);
}
});
}
return false;
});
});
</script>
Upvotes: 0
Views: 2745
Reputation: 716
you need to add references to jquery. that's a jquery script. you can reference them directly from the CDN.
Upvotes: 2