title: How to force datatype as JSON in ASP.Net 2.0
body: <p>I got the following working after spinning my head around a thousand times and then referring <a href="https://stackoverflow.com/questions/18882705/parserrror-syntaxerror-unexpected-token-load-partial-view-using-jquery-ajax">parserrror SyntaxError: Unexpected token &lt; - Load Partial View using jQuery Ajax in ASP.NET MVC 4</a></p>
  
  <p>I have the following code in my <code>ASP.Net 2.0</code> project. It works – but to get it to work, I am using <code>dataType: "html"</code>. When I use JSON as datatype I get a parse error: <code>Unexpected token &lt;</code></p>
  
  <p>How can we make it work with <code>JSON</code>?</p>
  
  <p>Note: Though I am using IE8, some of my users are still using IE6. So I need a solution that works in <strong>IE6</strong>.</p>
  
  <p><strong>jQuery Ajax</strong></p>
  
  <pre><code>   $.ajax({
              type: "GET",
              url: "admPlantParametersViewEdit.aspx/GetResult",
              contentType: "application/json; charset=utf-8",
              dataType: "html",
              success: function(msg) 
              {
                  alert("Hi");
              },
              error: errorFunction
          });
  </code></pre>
  
  <p><strong>VB.Net</strong></p>
  
  <pre><code>   &lt;WebMethod()&gt; _
      Public Shared Function GetResult() As String
  
          Return "hello"
  
      End Function
  </code></pre>
  
  <p><strong>Request and Response Headers</strong></p>
  
  <p><img src="https://i.stack.imgur.com/92j8b.png" alt="enter image description here"></p>
  
  <p><strong>References</strong></p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/14322984/differences-bettween-contenttype-and-datatype-in-jquery-ajax-function">Differences between contentType and dataType in jQuery ajax function</a></li>
  <li><a href="https://stackoverflow.com/questions/18701282/what-is-content-type-and-datatype-in-an-ajax-request">What is content-type and datatype in an AJAX request?</a></li>
  <li><a href="https://stackoverflow.com/questions/288850/how-to-return-json-from-a-2-0-asmx-web-service">How to return JSON from a 2.0 asmx web service</a></li>
  <li><a href="https://stackoverflow.com/questions/21720337/asp-net-ajax-pagemethods-call-load-whole-page-for-net-4-5-iis-7-5">ASP.NET AJAX PageMethods call load whole page for .NET 4.5 IIS 7.5</a></li>
  <li><a href="http://social.msdn.microsoft.com/Forums/vstudio/en-US/c412e600-0f4e-4a5b-8c45-bf77ed04f2a8/support-crossdomain-requests-specifically-multiple-methods-in-webinvoke-in-rest-wcf#e9e1a5a7-9a76-41a0-ab4f-fd6ad76b18aa" rel="nofollow noreferrer">Support cross-domain requests (specifically multiple methods in WebInvoke) in Rest WCF </a></li>
  <li><a href="https://stackoverflow.com/questions/1099787/jquery-ajax-post-sending-options-as-request-method-in-firefox">jQuery $.ajax(), $.post sending &quot;OPTIONS&quot; as REQUEST_METHOD in Firefox</a></li>
  <li><a href="https://stackoverflow.com/questions/9754767/cannot-set-content-type-to-application-json-in-jquery-ajax">Cannot set content-type to &#39;application/json&#39; in jQuery.ajax</a></li>
  </ol>