title: Can't get past "A jquery script reference is required in order to enable Ajax support in the "WebGrid" helper"
body: <p>I am having a similar as the user here:
  <a href="https://stackoverflow.com/questions/8590177/asp-net-mvc-3-0-webgrid-ajax-enabled">ASP.NET MVC 3.0 WebGrid - Ajax Enabled</a>
  and here:
  <a href="http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/22be0501-1b0b-496a-9d0c-f9f5138996ac" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/22be0501-1b0b-496a-9d0c-f9f5138996ac</a></p>
  
  <p>However none of the suggestions from those threads is helping here.  </p>
  
  <p>The specifics:  When running in my local debugger on my Windows 7/IIS 8 machine, I am getting the 'A jQuery script reference is required in order to enable Ajax support in the "WebGrid" helper' message after an ajax postback trying to update.  The same code however does not result in a problem in FF or when using IE against a version of the same code running on a server (IIS 6).  To make it more confusing, when I first <em>wrote</em> this code, I never had this problem - it has only recently started throwing error.</p>
  
  <p>When the error occurs, the 'correct' updated content flashes on the screen before the whole page redirects to just the partial view and throws the popup on screen.  It's like it works correctly but something then resets it and causes it to stop using ajax.</p>
  
  <p>To try to troubleshoot I replaced the .min versions of jquery with the full versions and step through the code.  In the debugger the jQuery behaves differently and triggers an "ajaxStop" because of the value in the global ajax counter.  When I run the external script debugger against the server version of the same code in the same IE browser, this does not appear to occur (though I still have the 'min' version on the server so can't see exactly).  It is this ajaxStop which appears to be forcing the webgrid to think that jQuery isn't loaded on the page and doesn't let the ajax behavior 'stick' - forcing a new page load of just the partial view.</p>
  
  <p>My page is not ultra simple:  the main View has several divs containing partial views - divSearch contains the search partial view which is the one calling the ajax postback, and divList contains the grid that needs to be updated based on the search results.  The controller method called by the search partial view renders the 'new' contents for the search results into a string and sends them back as part of a JsonResult, which is then assigned to the divList's html via jQuery.  (I use this technique in several places in the app, and I've verified that the string being sent back <em>is</em> the correct content for the partial view).  </p>
  
  <p>The jQuery (and all the other js includes) are at the top of the layout page and render before any of the partial views.  </p>
  
  <p>Main View:</p>
  
  <pre><code> @model WebUI.Areas.Admin.Models.Client.ManageClientsModel
   @{
      ViewBag.Title = "ManageClients";
      Layout = "~/Views/Shared/_AdminLayout.cshtml";
  }
  &lt;style type="text/css"&gt;
  .inv
  {
      visibility: hidden;
  }
  .vis
  {
      visibility: visible; 
  }
  &lt;/style&gt;
  
  &lt;h2&gt;ManageClients&lt;/h2&gt;
  &lt;div id="divSearch"&gt;
      @Html.Partial("_ClientSearch", Model.ClientList)
  &lt;/div&gt;
  &lt;div id="divList"&gt;
      @Html.Partial("_ClientList", Model.ClientList)
  &lt;/div&gt;
  &lt;br/&gt;
  &lt;div id="newSection"&gt;
  
      &lt;div id="divEdit"&gt; &lt;button class="toggleNew"&gt;
         Add Client
         &lt;/button&gt;
      &lt;/div&gt;
      div class="inv" id="divNew"&gt;  @Html.Partial("_Create", Model.ClientVM ) &lt;/div&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
     $(function () {
      $(".toggleNew").click(function () {
          $("#divNew").toggleClass("inv");
          return false;
      });
     });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Client Search partial:</p>
  
  <pre><code> @using  Core.Entities
   @model  WebUI.Areas.Admin.Models.Client.ClientListViewModel
   &lt;div id="clientSearch"&gt;
       &lt;form action="@Url.Action("JsonSearch","Client", new { area = "Admin"})"  
                   onsubmit="return formSearchSubmit(this);"  &gt;
           &lt;div class="divReturnErrors"&gt;&lt;/div&gt;
       @if(TempData["SearchName"] == null)
       {
           TempData["SearchName"] = Model.SearchName;
       }
           &lt;br/&gt;
           @Html.LabelFor(model =&gt; model.SearchName, "Search for client name:")
           @Html.EditorFor(model =&gt; model.SearchName)
            &lt;input type="submit" value="Search" name="btnSearch"   /&gt;
       &lt;/form&gt;
   &lt;/div&gt;
   &lt;script type="text/javascript"&gt;
     function formSearchSubmit(formToSubmit) {
       //this line submits the form data to the JsonSearch method
        $.post($(formToSubmit).attr("action"),
               { SearchName: $(formToSubmit).find("#SearchName").val() },
          function (data) {  //this is the callback from JsonSearch
                                          // that handles the results.
            if (data["IsSuccess"] == undefined || data["IsSuccess"] == false)
              $('div.divReturnErrors').html(data["Errors"]); 
                                //put errors in divReturnErrors
            else { //if it succeeds we stuff the string containing the 
                                //partial view into the _ClientList control's div to 
                               //replace previous grid.
                      $("#divList").html(data["PartialViewHtml"]);
                  }
              }, "json");
  
                         return false;
               }  
  &lt;/script&gt;
  </code></pre>
  
  <p>Client List partial view</p>
  
  <pre><code> @model WebUI.Areas.Admin.Models.Client.ClientListViewModel
   &lt;h2&gt;Clients&lt;/h2&gt;
    @helper TrueFalseToYesNo(bool val) {
      if (val)
      {
         &lt;span&gt;Yes&lt;/span&gt;
      }
      else
      {
         &lt;span&gt;No&lt;/span&gt;
      }
     }
  &lt;div id="clientListing"&gt;
  
    @{
      if(Model.SearchName != null)
      {
          TempData["SearchName"] = Model.SearchName;
      }
  
      var grid = new WebGrid&lt;NeedleFinder.Core.Entities.Client&gt;(null, rowsPerPage: 10, 
                canSort: false, defaultSort: "ClientName", 
                         ajaxUpdateContainerId:"clientListing");
      grid.Bind(Model.Clients, rowCount: Model.TotalRows, autoSortAndPage: false);
      @grid.GetHtml(htmlAttributes: new {id= "clientListing"},
          tableStyle: "table90",
          alternatingRowStyle: "duncanTableAltRows",
          headerStyle: "duncanTableHeaders",
          columns: grid.Columns(
              grid.Column(columnName: "Client ID", style: "logcolumn", 
                      format: item =&gt;              
                      @Ajax.ActionLink(((object)item.ClientID).ToString(), 
                      Model.LinkAction, new { id = item.ClientID }, new AjaxOptions { 
                      HttpMethod = "GET", UpdateTargetId = "divEdit", InsertionMode = 
                      InsertionMode.Replace })),
              grid.Column(columnName: "ClientName", style: "logcolumn"),
              grid.Column(columnName: "Abbreviation", style: "logcolumn"),
              //grid.Column(columnName: "IsActive", style: "logcolumn")
              grid.Column(columnName: "IsActive", style: "logcolumn", 
                 format: item =&gt; @TrueFalseToYesNo(item.IsActive))
              )
                 )
         }
  &lt;/div&gt;
  </code></pre>
  
  <p>The 'error' is occurring in this line:
                      $("#divList").html(data["PartialViewHtml"]);
  from the Client Search partial view ajax callback function.  This line jumps into the jQuery and while in there is calling ajaxStop.</p>
  
  <p>Please note I have already incorporated the suggestions from the other thread (jQuery includes at the top, putting the webgrid in a div with the same name as the ajaxUpdateContainer target, adding an id property to the webgrid with the same name as well.  The suggestion to load the partial explicitly in document.ready does not seem applicable to me since I am trying to populate this div with a string based on inputs rather than just plain load the default 'get' version of the partial view.  </p>
  
  <p>Here is the rendered html for the page when it first loads (it doesn't update when you do the ajax post anyway): (Apologies for the wonky formatting but adding 4 indents to each line didn't really work cleanly)</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;title&gt;ManageClients&lt;/title&gt;
  &lt;link href="/Content/Site.css" rel="stylesheet" type="text/css" /&gt;
  &lt;link href="/Content/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css" /&gt;
  
  &lt;script src="/Scripts/jquery-1.5.1.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="/Scripts/jquery-ui-1.8.18.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="/Scripts/jquery.unobtrusive-ajax.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="/Scripts/modernizr-1.7.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="/Scripts/jQuery.Validate.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="/Scripts/jquery.validate.unobtrusive.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;script type="text/javascript"&gt;
  
  $(document).ready(function () {
      $('.dateEditor').datepicker({ dateFormat: "mm/dd/yy" });
  });
  
  //This function should be called in your ajax post return are staying on same page
       after success and/or you do have server side errors that couldn't have been found
  //if there were still client side errors, otherwise you will still have the previous 
   validation errors.
  
  function ClearValidationErrors() {
  
      var container = $('form').find('[data-valmsg-summary="true"]');
      var list = container.find('ul');
  
      if (list &amp;&amp; list.length) {
          list.empty();
          container.addClass('validation-summary-valid').removeClass('validation-summary-
           errors');
      }
  }
  
  
  &lt;/script&gt;
  &lt;body&gt;
  &lt;style type="text/css"&gt;
  #topbar
  {
      background-color: Black;
      margin: 0px;
      padding: 5px;
  }
  
  #adminmenu_nav a
  {
      float: left;
      width: 150px;
  }
  
  .logcolumn
  {
      padding-left: 10px;
      padding-right: 10px;
      border: 1px solid #BBBBBB;
  }
  
  &lt;/style&gt;
  &lt;script&gt;
  $(function () {
      $("#adminmenu_nav a").button();
      $("#optionsPanel input").button();
      $(".asButton input").button();
  });
  &lt;/script&gt;
  &lt;div id="topbar"&gt;
  &lt;img style="margin-left:20px" src="/Content/Images/Logos/NFWhite.png" 
  alt="NeedleFinder" /&gt;
  &lt;/div&gt;
  &lt;div&gt;
  &lt;div id="adminmenu_nav" style="float: left"&gt;
      &lt;table&gt;
          &lt;tr&gt;&lt;td&gt;&lt;a href="/Admin/Client/ManageClients"&gt;Clients&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Cases&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;&lt;a href="/Admin/User/ManageUsers"&gt;Users&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Roles&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;&lt;a href="/Admin/Logging/Summary"&gt;Logs&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  &lt;div style="overflow: hidden"&gt;
      &lt;span class="validation-summary-errors"&gt;&lt;/span&gt;
      &lt;style type="text/css"&gt;
  .inv
  {
    visibility: hidden;
  }
  .vis
  {
      visibility: visible; 
  }
  &lt;/style&gt;
  
  &lt;h2&gt;ManageClients&lt;/h2&gt;
  &lt;div id="divSearch"&gt;
    &lt;div id="clientSearch"&gt;
     &lt;form action="/Admin/Client/JsonSearch" onsubmit="return formSearchSubmit(this);"  &gt;
          &lt;div class="divReturnErrors"&gt;&lt;/div&gt;
          &lt;br/&gt;
          &lt;label for="SearchName"&gt;Search for client name:&lt;/label&gt;
          &lt;input class="text-box single-line" id="SearchName" name="SearchName" 
            type="text" value="" /&gt;
           &lt;input type="submit" value="Search" name="btnSearch"   /&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
  function formSearchSubmit(formToSubmit) {
      //this line submits the form data to the JsonSearch method
      $.post($(formToSubmit).attr("action"),
              { SearchName: $(formToSubmit).find("#SearchName").val() },
          function (data) {  
          if (data["IsSuccess"] == undefined || data["IsSuccess"] == false)
              $('div.divReturnErrors').html(data["Errors"]); 
           else 
                       { 
              $("#divList").html(data["PartialViewHtml"]);
          }
      }, "json");
  
      return false;
      }  
  &lt;/script&gt;
  &lt;/div&gt;
  &lt;div id="divList"&gt;
    &lt;h2&gt;Clients&lt;/h2&gt;
  
    &lt;div id="clientListing"&gt;
  
  &lt;script type="text/javascript"&gt;if (typeof(jQuery)=='undefined') alert("A jQuery script 
  reference is required in order to enable Ajax support in the \"WebGrid\" helper.");
  &lt;/script&gt;&lt;table class="table90" id="clientListing"&gt;&lt;thead&gt;&lt;tr 
    class="duncanTableHeaders"&gt;&lt;th scope="col"&gt;Client ID&lt;/th&gt;&lt;th 
    scope="col"&gt;ClientName&lt;/th&gt;&lt;th scope="col"&gt;Abbreviation&lt;/th&gt;&lt;th 
    scope="col"&gt;IsActive&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tfoot&gt;&lt;tr&gt;&lt;td colspan="4"&gt;1 &lt;a href="#" 
    onclick="$(&amp;#39;#clientListing&amp;#39;).load(&amp;#39;/Admin/Client/ManageClients?page=2&amp;
    amp;__=634750282355486955 #clientListing&amp;#39;);"&gt;2&lt;/a&gt; &lt;a href="#" 
    onclick="$(&amp;#39;#clientListing&amp;#39;).load(&amp;#39;/Admin/Client/ManageClients?page=3&amp;
    amp;__=634750282355506956 #clientListing&amp;#39;);"&gt;3&lt;/a&gt; &lt;a href="#" 
    onclick="$(&amp;#39;#clientListing&amp;#39;).load(&amp;#39;/Admin/Client/ManageClients?page=4&amp;
    amp;__=634750282355516957 #clientListing&amp;#39;);"&gt;4&lt;/a&gt; &lt;a href="#" 
    onclick="$(&amp;#39;#clientListing&amp;#39;).load(&amp;#39;/Admin/Client/ManageClients?page=5&amp;
    amp;__=634750282355536958 #clientListing&amp;#39;);"&gt;5&lt;/a&gt; &lt;a href="#" 
    onclick="$(&amp;#39;#clientListing&amp;#39;).load(&amp;#39;/Admin/Client/ManageClients?page=2&amp; 
    amp;__=634750282355546959 #clientListing&amp;#39;);"&gt;&amp;gt;&lt;/a&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tfoot&gt;&lt;tbody&gt;
    &lt;tr&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true" data-ajax-method="GET" data-ajax-
    mode="replace" data-ajax-update="#divEdit" href="/Admin/Client/_Edit/2042"&gt;2042&lt;/a&gt;
    &lt;/td&gt;&lt;td class="logcolumn"&gt;ABC Legal&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC123&lt;/td&gt;&lt;td 
    class="logcolumn"&gt;           &lt;span&gt;Yes&lt;/span&gt;
  
    &lt;/td&gt;&lt;/tr&gt;&lt;tr class="duncanTableAltRows"&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true" 
    data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="#divEdit" 
    href="/Admin/Client/_Edit/2044"&gt;2044&lt;/a&gt;&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC Legal 
    3&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC125&lt;/td&gt;&lt;td class="logcolumn"&gt;           
    &lt;span&gt;Yes&lt;/span&gt;
  
    &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true" data-ajax-method="GET" 
    data-ajax-mode="replace" data-ajax-update="#divEdit" href="/Admin/Client/_Edit
    /2045"&gt;2045&lt;/a&gt;&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC Legal 4b&lt;/td&gt;&lt;td 
    class="logcolumn"&gt;ABC4bb&lt;/td&gt;&lt;td class="logcolumn"&gt;           &lt;span&gt;Yes&lt;/span&gt;
  
    &lt;/td&gt;&lt;/tr&gt;&lt;tr class="duncanTableAltRows"&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true" 
    data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="#divEdit" 
    href="/Admin/Client/_Edit/2047"&gt;2047&lt;/a&gt;&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC Legal 
    6&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC6&lt;/td&gt;&lt;td class="logcolumn"&gt;           &lt;span&gt;No&lt;/span&gt;
  
    &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true" data-ajax-method="GET" 
    data-ajax-mode="replace" data-ajax-update="#divEdit" href="/Admin/Client/_Edit
    /2048"&gt;2048&lt;/a&gt;&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC Legal 7&lt;/td&gt;&lt;td 
    class="logcolumn"&gt;ABC7&lt;/td&gt;&lt;td class="logcolumn"&gt;           &lt;span&gt;Yes&lt;/span&gt;
  
    &lt;/td&gt;&lt;/tr&gt;&lt;tr class="duncanTableAltRows"&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true"   
    data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="#divEdit" 
    href="/Admin/Client/_Edit/2049"&gt;2049&lt;/a&gt;&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC Legal 
    8a&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC8a&lt;/td&gt;&lt;td class="logcolumn"&gt;           
    &lt;span&gt;Yes&lt;/span&gt;
  
    &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true" data-ajax-method="GET" 
    data-ajax-mode="replace" data-ajax-update="#divEdit" href="/Admin/Client/_Edit
    /2050"&gt;2050&lt;/a&gt;&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC Legal 9&lt;/td&gt;&lt;td 
    class="logcolumn"&gt;ABC9&lt;/td&gt;&lt;td class="logcolumn"&gt;           &lt;span&gt;Yes&lt;/span&gt;
  
    &lt;/td&gt;&lt;/tr&gt;&lt;tr class="duncanTableAltRows"&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true" 
    data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="#divEdit" 
    href="/Admin/Client/_Edit/2043"&gt;2043&lt;/a&gt;&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC 
    Legal2&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC124&lt;/td&gt;&lt;td class="logcolumn"&gt;           
    &lt;span&gt;Yes&lt;/span&gt;
    &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true" data-ajax-method="GET" 
    data-ajax-mode="replace" data-ajax-update="#divEdit" href="/Admin/Client/_Edit
    /2046"&gt;2046&lt;/a&gt;&lt;/td&gt;&lt;td class="logcolumn"&gt;ABC Legal5&lt;/td&gt;&lt;td 
    class="logcolumn"&gt;ABC5&lt;/td&gt;&lt;td class="logcolumn"&gt;           &lt;span&gt;Yes&lt;/span&gt;
    &lt;/td&gt;&lt;/tr&gt;&lt;tr class="duncanTableAltRows"&gt;&lt;td class="logcolumn"&gt;&lt;a data-ajax="true" 
    data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="#divEdit" 
    href="/Admin/Client/_Edit/2051"&gt;2051&lt;/a&gt;&lt;/td&gt;&lt;td class="logcolumn"&gt;ACE Legal 
    1&lt;/td&gt;&lt;td class="logcolumn"&gt;ACE1&lt;/td&gt;&lt;td class="logcolumn"&gt;           
    &lt;span&gt;Yes&lt;/span&gt;
  
    &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
  
  
    &lt;/div&gt;
  &lt;br/&gt;
  &lt;div id="newSection"&gt;
  
     &lt;div id="divEdit"&gt; &lt;button class="toggleNew"&gt;
       Add Client
    &lt;/button&gt;&lt;/div&gt;&lt;!-- placeholder for _Edit., will replace button when editing//--&gt;
    &lt;div class="inv" id="divNew"&gt;
   &lt;form action="/Admin/Client/JsonCreate" onsubmit="return formCreateSubmit(this);"&gt;
    &lt;div&gt;
      &lt;div class="titleText"&gt;Add Client&lt;/div&gt;
      &lt;div class="divClientSideVal"&gt;
      &lt;div class="validation-summary-valid" data-valmsg-summary="true"&gt;&lt;ul&gt;&lt;li 
        style="display:none"&gt;&lt;/li&gt;
      &lt;/ul&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="divCreateErrors"&gt;&lt;/div&gt;
      &lt;fieldset&gt;
          &lt;table&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;label for="CurrentClient_ClientName"&gt;Name&lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;input data-val="true" data-val-length="Client Name must be 50 
                         characters or fewer" data-val-length-max="50" data-val-
                        required="Client Name is required." 
                       id="CurrentClient_ClientName" name="CurrentClient.ClientName" 
                        style="width: 120px;" type="text" value="" /&gt; 
                  &lt;/td&gt;
                  &lt;td&gt;&lt;span class="field-validation-valid" data-valmsg-
                 for="CurrentClient.ClientName" data-valmsg-replace="false"&gt;*&lt;/span&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;label for="CurrentClient_Abbreviation"&gt;Abbreviation&lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;input data-val="true" data-val-length="Abbreviation must be 6 
                  characters or fewer" data-val-length-max="6" data-val-
                  required="Abbreviation is required." id="CurrentClient_Abbreviation" 
                  name="CurrentClient.Abbreviation" style="width: 120px;" type="text" 
                  value="" /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;span class="field-validation-valid" data-valmsg-
                 for="CurrentClient.ClientName" data-valmsg-replace="false"&gt;*&lt;/span&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;label for="CurrentClient_IsActive"&gt;Is Active:&lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
  
                  &lt;input data-val="true" data-val-required="The IsActive field is 
                  required." id="CurrentClient_IsActive" name="CurrentClient.IsActive" 
                   type="checkbox" value="true" /&gt;&lt;input name="CurrentClient.IsActive" 
                    type="hidden" value="false" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Enable for installations:&lt;/td&gt;
                  &lt;td&gt;
                      &lt;select Multiple="multiple" id="SelectedInstallations" 
                multiple="multiple" name="SelectedInstallations" style="width: 
                 120px;"&gt;       
                   &lt;option value="1"&gt;Dev&lt;/option&gt;
                   &lt;option value="2"&gt;FakeDev&lt;/option&gt;
                  &lt;/select&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;&lt;/fieldset&gt;
      &lt;p&gt;
          &lt;input type="submit" value="Create" name="btnCreate"  /&gt;
      &lt;/p&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  
  &lt;script type="text/javascript"&gt;
  
  
  function formCreateSubmit(formToSubmit) {
  
      var installations = "";
      $('#SelectedInstallations option').each(function (i) {
          if (this.selected == true) {
              if (installations.length &gt; 0) {
                  installations += ",";
              }
              installations += this.value;
          }
      });
  
      //this line submits the form data to the JsonCreate method
      $.post($(formToSubmit).attr("action"),
              { ClientName: $(formToSubmit).find("#CurrentClient_ClientName").val(),
                  Abbreviation:  
                 $(formToSubmit).find("#CurrentClient_Abbreviation").val(),
                  IsActive: 
               $(formToSubmit).find("#CurrentClient_IsActive").is(':checked'),
                  SelectedInstallations: installations,
                  Action: "Create"
              },
      function (data) {  
      if (data["IsSuccess"] == undefined ||  data["IsSuccess"] == false)
      {
         if (data["Errors"] != undefined &amp;&amp;                          
                     data["Errors"].length &gt; 0) 
                  {
                          ClearValidationErrors();                    
  
       ('div.divCreateErrors').html(data["Errors"]);                      
        } else {
  $('div.divCreateErrors').html("");
     }
  
  } else { 
          window.location = "/Admin/Client/ManageClients";
      }
  }, "json");
  
      return false;
     }
  &lt;/script&gt; &lt;/div&gt;&lt;!-- placeholder for _Create //--&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
     $(function () {
      $(".toggleNew").click(function () {
          $("#divNew").toggleClass("inv");
          return false;
      });
     });
  
  &lt;/script&gt;
  
  
  
    &lt;/div&gt;
  &lt;/div&gt;
    &lt;div class="InternalMenu"&gt;&lt;a href="/Admin/Logging"&gt;Logging&lt;/a&gt; - &lt;a href="/Admin
            /Client/ManageClients"&gt;Client&lt;/a&gt;&lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any suggestions would be greatly appreciated as I'm pretty stumped as to what is causing the problem. </p>