如何調用ws
1) .net Ajax scriptManager屬性設定
<asp:ScriptManager ID="ScriptManager1" runat="server" >
<Services>
<asp:ServiceReference Path="selfWS.asmx" />
</Services>
</asp:ScriptManager>
2)ws内容
public class selfWS : System.Web.Services.WebService {
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
}
這裡要為ws添加[ScriptService]标貼
它所在的名字空間為:System.Web.Script.Services
3)用戶端調用
類.方法(參數,資訊成功處理後的結果)
selfWS.HelloWorld(OnRequestComplete);//此方法沒有參數,這裡不添參數,隻有一個處理方法
定義處理方法
function OnRequestComplete(result)
{
alert(result);
部落格園大道至簡
<a href="http://www.cnblogs.com/jams742003/" target="_blank">http://www.cnblogs.com/jams742003/</a>
轉載請注明:部落格園