jQuery ui dialog - getting 500 error on post

jQuery ui dialog - getting 500 error on post

Hi everybody,


I am trying the following code for my dialog


var $dlg = $("#add-edit-dialog").dialog({
   autoOpen: false,
   show: "blind",
   closeOnEscape: true,
   resizable: true,
   width: 1200,
   height: 750,
   minHeight: 600,
   minWidth: 950,
   buttons: {
      "Save": function () {


         if ($("#add-edit-form").valid()) {


            var urlLoc = '/Client/Edit/' + currentId;
            if ($('#fntype').val() === "Add")
               urlLoc = '/Client/Add';


            var oForm = $("#add-edit-form").serialize();
            oForm = oForm.concat($('#frmClientsSearch').serialize());


            $.ajax({
               type: 'POST',
               url: urlLoc,
               dataType: 'json',
               data: oForm, 
               contentType: 'application/json',
               success: function (result) {
                  $('#flexClients').flexAddData(result);
               }
            });
            $(this).dialog('close');
         } else return false;


      },
      Cancel: function () {
         $(this).dialog("close");
         clearForm();
         if (validator)
            validator.resetForm();
      }
   },
   close: function () { clearForm(); },
   open: function () {
   }
});


where the form (the dialog) is this one:


  1. @using CardNumbers.Helper
  2. @model CardNumbers.Models.ClientViewModel
  3.   <form id="add-edit-form">
  4.     <fieldset>
  5.         <legend>Client Info</legend>


  6.         @Html.ValidationSummary(true)
  7.        
  8.         <input type="hidden" id="fntype" name="fntype">


  9.         @Html.HiddenFor(m => m.ClientId)
  10.         @Html.EditorFor(m => m.ClientNumber, EditorTemplate.TextBox)


  11.         @Html.EditorFor(m => m.ClientName, EditorTemplate.TextBox)


  12.         @Html.EditorFor(m => m.Client.Address, EditorTemplate.EditBox)


  13.         <div id="ContactsInfo">


  14.             <div id="Contact1">


  15.                 @Html.EditorFor(m => m.Client.Contact1)


  16.             </div>


  17.             <div id="Contact2">


  18.                 @Html.EditorFor(m => m.Client.Contact2)
  19.             </div>
  20.         </div>


  21.        @* <div id="SaveCancel" class="float-right">
  22.             <button id="btnSave">Save</button>
  23.             <button type="reset" id ="btnCancel" name="Reset">Cancel</button>
  24.         </div>*@
  25.     </fieldset>


  26.  </form>
The error I am getting is this:

 <head>  <title>Invalid JSON primitive: fntype.</title>  <meta name="viewport" content="width=device-width" />  <style>
 So, the problem is with fnType. Do you see what I am missing and is there a way to exclude the fntype from serialize() (I don't really need it, I think)?

oForm variable is this:

"fntype=&ClientId=142&ClientNumber=6420&ClientName=Adventure+Sports+Cntr&Client.Address=tr&Client.Contact1.Contact=&Client.Contact1.Email=&Client.Contact1.phoneInfo.Phone=&Client.Contact1.phoneInfo.Ext=&Client.Contact2.Contact=&Client.Contact2.Email=&Client.Contact2.phoneInfo.Phone=&Client.Contact2.phoneInfo.Ext=searchClientNo=&searchClientName=a"