title: jqGrid Content Type during Form Edit
body: <p>I am new to jqGrid. However, successfully able to develop an application using jqGrid mainly with the help of Oleg's answers.
  I load a jqGrid based on selection of drop down. the data is returned from a Web Service (asmx) file. 
  The code is some thing like this</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>jQuery("#list").jqGrid({
      url: '&lt;%= ResolveClientUrl("OfficeData.asmx/GetSCFS_RO") %&gt;',
      editurl: '&lt;%= ResolveClientUrl("OfficeData.asmx/SaveFPSUpdates") %&gt;',
      datatype: "json",
      mtype: 'POST',
      ajaxGridOptions: { contentType: 'application/json; charset=utf-8' }, 
      ajaxEditOptions: { contentType: 'application/json; charset=utf-8', dataType: 'json' },
      serializeGridData: function (postData) {
          // return null;
          if (postData.OfficeId === undefined) { postData.OfficeId = 0; }
          else {
              postData.OfficeId = officeId;
          }
          return JSON.stringify(postData);
      }, 
      jsonReader: { repeatitems: false, root: "d.rows", page: "d.page",
          total: "d.total", records: "d.records" },
      colNames: ['FPSCode',  'Owner Name ', 'Licese_No', 'ShopAddress', 'Village',
          'License Valid From', 'Valid To','FPS Type','WholeSalerName',  'Mobile'],
      colModel: [{ name: 'FPSCode', index: 'FPSCode', width: 60, align: 'left',
          editable:true, editrules:{required:true}, 
          editoptions:{ 
              dataInit: function(element) { 
                  $(element).attr("readonly", "readonly"); 
              } 
          }
      },
      ......
  </code></pre>
  
  <p>Firebug shows the following Post header</p>
  
  <p><b>Response Headers </b></p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>......
  Content-Type      application/json; charset=utf-8
  Date              Tue, 20 Nov 2012 14:20:34 GMT
  Server            ASP.NET Development Server/10.0.0.0
  X-AspNet-Version  4.0.30319
  </code></pre>
  
  <p><b>Request Headers</b></p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>Accept            application/json, text/javascript, */*; q=0.01
  Accept-Encoding   gzip, deflate
  Accept-Language   en-US,en;q=0.5
  Cache-Control     no-cache
  Connection        keep-alive
  Content-Length    105
  ..........
  </code></pre>
  
  <p>As expected the response I get is JSON object.</p>
  
  <p>However the Form submit always sends <code>Content-Type</code> as <code>application/x-www-form-urlencoded; charset=UTF-8</code></p>
  
  <p><b>Response Headers </b></p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>Cache-Control     private, max-age=0
  Connection        Close
  Content-Length    95
  Content-Type      text/xml; charset=utf-8
  Date              Tue, 20 Nov 2012 14:20:46 GMT
  Server            ASP.NET Development Server/10.0.0.0
  </code></pre>
  
  <p><b>Request Headers</b></p>
  
  <pre class="lang-none prettyprint-override"><code>Accept            */*
  Accept-Encoding   gzip, deflate
  Accept-Language   en-US,en;q=0.5
  Cache-Control     no-cache
  Connection        keep-alive
  Content-Length    254
  Content-Type      application/x-www-form-urlencoded; charset=UTF-8
  Cookie            ASP.NET_SessionId=utts2wlhdto4xhae34fzqkt4
  Host              localhost:18017
  Pragma            no-cache
  Referer           Account/FPSUpdate.aspx
  User-Agent        Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0
  X-Requested-With  XMLHttpRequest
  X-AspNet-Version  4.0.30319
  </code></pre>
  
  <p>As suggested at Stackoverflow I have used </p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>ajaxEditOptions:  { contentType: 'application/json; charset=utf-8', dataType: 'json' } , 
  </code></pre>
  
  <p>I tried even to use <code>ajaxEditoptions</code> at</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>jQuery.extend(jQuery.jgrid.edit, {
      ajaxEditOptions:  { contentType: 'application/json; charset=utf-8', dataType: 'json' },
      ...
  });
  </code></pre>
  
  <p>However there is no change in the <code>Content-Type</code>.
  As a consequence I always get an XML response from the server for the Update. The output from the server is</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;string xmlns="http://tempuri.org/"&gt;Data Saved&lt;/string&gt;
  </code></pre>
  
  <p>I am unable to fix the Mime type to JSON. Please help.</p>