這傢伙救了我的一天。
http://blogs.microsoft.co.il/blogs/idof/archive/2011/07.aspx
我要放置一些在這裏他的筆記,以防萬一該網頁死亡的一天。 (我討厭發現「你的答案就在這裏」鏈接,然後將鏈接已經死了。)
<behaviors>
<endpointBehaviors>
<behavior name="webSupport">
<webHttp />
<CorsSupport />
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="CorsSupport" type="WebHttpCors.CorsSupportBehaviorElement, WebHttpCors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<services>
<service name="Service.JSonService">
<endpoint address="http://localhost:8080" behaviorConfiguration="webSupport」 binding="webHttpBinding" contract="Service.IJSonService" />
</service>
</services>
現在,你必須找到他所謂的「WebHttpCors.dll」下載庫。
但是,有足夠的(上面)來幫助你谷歌/ bing你的方式來解決。
扔我一個循環(在我的場景中)的部分是IE工作,但Firefox無法正常工作。
我的原始頁面爲:
http://localhost:53692/test/WCFCallTestViaJQ14.htm
所以我的服務是:
http://localhost:8002/MyWCFService/MyWCFMethodByWebGet?state=NC&city=Raleigh
所以我不得不本地主機< < - >>本地主機的流量。
****但港口是不同的。 (53692和8002)****
IE可以。 Firefox不適合它。
然後,你必須記住,每個瀏覽器處理他們的.Send()請求不同(在JQUERY裏面)。
這一切都有道理。
//JavaScript snipplet
if (window.XMLHttpRequest) {
returnObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
returnObject = new ActiveXObject("Microsoft.XMLHTTP");
} else {
msg = "Your browser doesn't support AJAX!";
}
這裏有一些關鍵詞,我一直在使用googling/binging,最終導致我的某處。
Result: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.statusText]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://localhost:53692/test/WCFCallTestViaJQ14.htm :: HandleJQueryError :: line 326" data: no]
XMLHttpRequest Send "NS_ERROR_FAILURE"
JQuery Ajax WCF Self Hosted CORS JSON
你有沒有遇到過這種情況? –