1

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 server. 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>
3
  • Have you checked the HTML source in FF? Please check if the path to the script files are correct. Also try to access the scripts by using the path from the source and paste it into the browser. Commented Jun 17, 2011 at 18:07
  • Have you referenced jquery and jquery UI as well in your page? Can't see them anywhere in the code you provided. Maybe they are referenced in your layout? If this is the case have you verified with FireBug that the path you provided to those scripts is correct and that the server doesn't return 404 errors? Commented Jun 17, 2011 at 18:19
  • Yes, they are in layout and the path is correct. I used @Url.content but result is the same. Commented Jun 17, 2011 at 20:50

2 Answers 2

1

You might try referencing your scripts like this:

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the reply, both ways generate something like this: <script src=/Scripts/...
gibson can you please take a look at my all new comments.
@CaseyWilliams @scottm Hi guys, can you please take a look at my issue.
0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.