title: XMLHttpRequest cannot load [url] Response for preflight has invalid HTTP status code 400
body: <p>I am getting an error saying "XMLHttpRequest cannot load [url] Response for preflight has invalid HTTP status code 400.</p>
  
  <p>I tried calling from a form and it appears to be working. I debug the service from inside Visual Studio and it worked just fine</p>
  
  <p>Calling the service this way:</p>
  
  <pre><code>                    $.ajax({
                          type: "POST",
                          url: "http://localhost:54664/PopulateCombo.svc/GetCodigo",
                          data: { EmpresaId: 100100, LanguageId: 5, TipoId: TipoId },
                          contentType: "application/json; charset=utf-8",
                          dataType: "json",
                          success: function (response) {
                              var models = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                              for (var i = 0; i &lt; models.length; i++) {
                                  var val = models[i];
                                  var text = models[i];
                                  $('#ddValor').addOption(val, text, false);
                              }
                          }
                      });
  </code></pre>
  
  <p>My web config.</p>
  
  <pre><code>            &lt;system.webServer&gt;
              ....
              &lt;httpProtocol&gt;
                    &lt;customHeaders&gt;
                      &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
                      &lt;add name="Access-Control-Allow-Headers" value="Accept, Content-Type, Origin" /&gt;
                      &lt;add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /&gt;
                    &lt;/customHeaders&gt;
                  &lt;/httpProtocol&gt;
              ....
                &lt;/system.webServer&gt;
  
                &lt;system.serviceModel&gt;
                  &lt;bindings&gt;
                    &lt;basicHttpBinding&gt;
                      &lt;binding name="BasicHttpBinding_IPopulateCombo" sendTimeout="00:05:00" /&gt;
                      &lt;binding name="BasicHttpBinding_IPopulateCombo1" /&gt;
                    &lt;/basicHttpBinding&gt;
                  &lt;/bindings&gt;
                  &lt;client&gt;
  
                    &lt;endpoint address="http://localhost:54664/PopulateCombo.svc"
                      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPopulateCombo1"
                      contract="ACPSvc.IPopulateCombo" name="BasicHttpBinding_IPopulateCombo1" /&gt;
                  &lt;/client&gt;
                &lt;/system.serviceModel&gt;
  </code></pre>