Ajax.BeginForm() not working MVC - uncaught javascript error - unexpected token (

I am trying to do ajax form in MVC here is my step: I create Model class MyModel:

public class MyModel
{
    [Required]
    public string Name { get; set; }
    public int iexNum { get; set; }
    public InMyModel inMyModel { get; set; }
    public string selectedCombo { get; set; }
    public List<string> collection { get; set; }
}

public class InMyModel
{
    public string Name { get; set; }
    public int Num { get; set; }
}

I added in my layout this two scripts:

<script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

and this is my form:

          @{
    Html.EnableClientValidation();
}
@using (Ajax.BeginForm("MyFunction", "Home",
    new AjaxOptions
    {
        HttpMethod = "POST",
        OnBegin = "function(){ loadingPanel.Show(); }",
        OnComplete = "function(){ loadingPanel.Hide(); }",
        UpdateTargetId = "mycontent",
        InsertionMode = InsertionMode.Replace
    },
    new
    {
        id = "validationForm",
        @class = "edit_form",
        style = "height: 200px; width: 600px;"
    }))
{

    <div id="mycontent">
        @Html.Partial("_ajaxForm", Model)
    </div>

}

when I am running the application and press the form I get javascript uncaught error as in this screenshot:

As you can see there is an uncaught error in jquery.unobstusive.ajax.min.js Someone help please!?

Answers


I found the problem this line is not good!

    OnBegin = "function(){ loadingPanel.Show(); }",
    OnComplete = "function(){ loadingPanel.Hide(); }",

I changed it to:

    OnBegin = "onBegin",
    OnComplete = "onEnd",

and implement these function in my javascript file and it is work!


Need Your Help

How to do “sequential” Job Scheduling (Quartz?)

java scheduling quartz-scheduler

I'm making use of Quartz Scheduling and there are 2 jobs. First Job is performing the tasks for around 2 minutes and the Second one is to be setup for Cleaning Operations of Temporary Files. So, I ...

Program option library for portable code

c++ portability boost-program-options

I have a portable code running on Visual C++ 2008 and RHEL 5.3 (gcc 4.x.x).