顯示具有 WebService 標籤的文章。 顯示所有文章
顯示具有 WebService 標籤的文章。 顯示所有文章

2012年9月27日 星期四

jQuery ajax post 在IIS中無法存取 WebService (*.asmx)



有某段程式碼如下,在本機測試時沒問題,一放到IIS上就失敗

$.ajax({
type: "POST",
url: "/Services/CommonService.asmx/QueryNation",
data: '',
async: false,
success: function (result) {
var msg = $(result.lastChild).text();
alert(msg);
}
});


有兩種方式解決:

1. 在IIS上設定虛擬目錄,指向存放webservice的資料夾

2. 在web.config上設定webService區段,如下:
<!-- 設定允許Service存取 -->
<configuration>
 <system.web>
    <webServices>
      <protocols>
        <add name="HttpPost" />
      </protocols>
    </webServices>
 </system.web>
</configuration>

2011年9月22日 星期四

當網站部屬到IIS後 使用jQuery ajax呼叫webService(.asmx)失敗

在本機開發的時候可以正常呼叫,一但部署到IIS上面就發成錯誤
檢查error status為404錯誤

解決方式:
在web.config加入


<configuration>
  <system.web>
    <webServices>
       <protocols>
          <add name="HttpPost" />
       </protocols>
    </webServices>
  </system.web>
</configuration>