Firefox "jQuery is not defined" error in asp.net mvc 3
I'm using asp.net mvc also using jQuery ui dialog, i'm showing a partialview in a jQuery dialog but Firefox give me an error on these two files below. I post an Ajax.BeginForm() to serv开发者_开发百科er. on first post it's working fine but on sencond post it destroys my dialog.
jquery.validate.min.js
jquery.validate.unobtrusive.min.js
Error : jQuery is not defined
I dont have this problem in IE, please help.
@model MvcSmkApplication.Models.LoginModel
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Ajax.BeginForm("AuthenticateUser", "Members", new AjaxOptions
{
HttpMethod = "POST",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "LoginForm",
OnSuccess = "OnSuccess",
}))
{
<div id="LoginForm">
@Html.ValidationSummary(true)
<fieldset>
<legend></legend>
<div class="editor-label">
@Html.LabelFor(model => model.EmailAddress)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.EmailAddress)<br />
@Html.ValidationMessageFor(model => model.EmailAddress)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Password)<br />
@Html.ValidationMessageFor(model => model.Password)
</div>
@foreach (ModelState modelState in ViewData.ModelState.Values)
{
foreach (ModelError error in modelState.Errors)
{
<div style="color: Red;">@error.ErrorMessage</div>
}
}
<div style="float: right;">
<input type="submit" value="Login" class="buttonAsLink" />
</div>
</fieldset>
</div>
}
<script type="text/javascript">
function OnSuccess(e) {
if (e["success"] == "true") {
$("#dialog").dialog("close");
location.reload();
}
else {
//alert('error');
}
}
</script>
You might try referencing your scripts like this:
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
Here is the solution which I found it after 3 weeks research.
<script type="text/javascript">
function OnSuccess(e) {
if (e["success"] == "true") {
$("#dialog").dialog("close");
location.reload();
}
else {
$("#dialog").html(e);
return false;
}
}
</script>
精彩评论