Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ajax调用WCF服务错误“405方法不允许”_Jquery_Ajax_Wcf - Fatal编程技术网

Jquery ajax调用WCF服务错误“405方法不允许”

Jquery ajax调用WCF服务错误“405方法不允许”,jquery,ajax,wcf,Jquery,Ajax,Wcf,我有一个webservice&我使用jqueryajax调用来调用它 该服务托管在同时托管silverlight项目的项目中 在web.config中,我有 <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="

我有一个webservice&我使用jqueryajax调用来调用它 该服务托管在同时托管silverlight项目的项目中 在web.config中,我有

<system.webServer>    
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type, Accept, X-Requested-With" />
        <add name="Access-Control-Allow-Methods" value="GET, POST, OPTIONS" />
      </customHeaders>
    </httpProtocol>
</system.webServer>
在Chrome中,该服务确实成功了,但在IE10和Firefox19中它失败了&我收到了错误消息。Chrome首先做选项请求,结果是405,就像IE和firefox中的一样,但之后Chrome会自动做另一个POST请求,结果是200。IE&Firefox不这样做,这是另一个POST请求

我有什么遗漏吗?
感谢您的回答

您是否正在跨域使用该服务?只是检查一下可能性。
<service behaviorConfiguration="ThreeBirds.HttpServiceBehavior" name="TheWire.Server.Endpoints.LeadCaptureService">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="AspNetAjaxBehavior" name="LeadCaptureService" contract="ThreeBirds.Services.Contracts.ILeadCaptureService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
<behavior name="AspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
var webMethod = 'RecordSubscribe';
                                        var formFields = {

                                            dealerid: dealerID,
                                            firstname: $(form).find(".inputFirstName").val(),
                                            lastname: $(form).find(".inputLastName").val(),
                                            email: $(form).find(".inputEmail").val()
                                        };

                                        $.ajax({
                                            type: "POST",
                                            url: "http://thewire.3birdsmarketing.com/wire/endpoints/Leadcapture.svc/Record" + webMethod,
                                            processData: false,
                                            contentType: "application/json",
                                            data: JSON.stringify(formFields),
                                            allowCrossDomain: true,
                                            dataType: "json",
                                            success: function (data, status, req) {                                                
                                                alert("Thank you " + formFields.firstname + " " + formFields.lastname + ", your information has been submitted.");

                                            },
                                            error: function (data) {
                                                alert('Sorry ! There was an error sending your data. Please try it again.');
                                            }
                                        });