title: Cannot set content-type to 'application/json' in jQuery.ajax
body: <p>When I have this code</p>
  
  <pre><code>$.ajax({
      type: 'POST',
      //contentType: "application/json",
      url: 'http://localhost:16329/Hello',
      data: { name: 'norm' },
      dataType: 'json'
  });
  </code></pre>
  
  <p>in Fiddler I can see following raw request</p>
  
  <pre><code>POST http://localhost:16329/Hello HTTP/1.1
  Host: localhost:16329
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
  Accept: application/json, text/javascript, */*; q=0.01
  Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
  Accept-Encoding: gzip, deflate
  Connection: keep-alive
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  Referer: http://localhost:14693/WebSite1/index.html
  Content-Length: 9
  Origin: http://localhost:14693
  Pragma: no-cache
  Cache-Control: no-cache
  
  name=norm
  </code></pre>
  
  <p>But what I'm trying is to set content-type from <strong>application/x-www-form-urlencoded</strong> to <strong>application/json</strong>. But this code</p>
  
  <pre><code>$.ajax({
      type: "POST",
      contentType: "application/json",
      url: 'http://localhost:16329/Hello',
      data: { name: 'norm' },
      dataType: "json"
  });
  </code></pre>
  
  <p>Generates strange request (which I can see in Fiddler)</p>
  
  <pre><code>OPTIONS http://localhost:16329/Hello HTTP/1.1
  Host: localhost:16329
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
  Accept-Encoding: gzip, deflate
  Connection: keep-alive
  Origin: http://localhost:14693
  Access-Control-Request-Method: POST
  Access-Control-Request-Headers: content-type
  Pragma: no-cache
  Cache-Control: no-cache
  </code></pre>
  
  <p>Why is that? What is OPTIONS when it should be POST there? And where is my content-type set to application/json? And request parameters has gone for some reason.</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>On server side I have really simple RESTful service.</p>
  
  <pre><code>[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  public class RestfulService : IRestfulService
  {
      [WebInvoke(
          Method = "POST",
          UriTemplate = "Hello",
          ResponseFormat = WebMessageFormat.Json)]
      public string HelloWorld(string name)
      {
          return "hello, " + name;
      }
  }
  </code></pre>
  
  <p>But for some reason I can't call this method with parameters.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Sorry for not answering so long. </p>
  
  <p>I've added these headers to my server response</p>
  
  <pre><code> Access-Control-Allow-Origin: *
   Access-Control-Allow-Headers: Content-Type
   Access-Control-Allow-Methods: POST, GET, OPTIONS
  </code></pre>
  
  <p>It didn't help, I have <strong>Method not allowed</strong> error from server.</p>
  
  <p>Here is what my fiddler says</p>
  
  <p><img src="https://i.imgur.com/jIuk0.png" alt="enter image description here"></p>
  
  <p>So, now I can be sure that my server accepts <em>POST, GET, OPTIONS</em> (if response headers work like I expect). But why "Method not allowed"?</p>
  
  <p>In WebView response from server (you can see <em>Raw</em> response on picture above) looks like this</p>
  
  <p><img src="https://i.stack.imgur.com/jX2AW.png" alt="enter image description here"></p>