Ajax--WebService返回枚举

枚举:

public enum WeekDay
{
    Sat, Sun, Mon, Tue, Wed, Thu, Fri
}
 

WebService:

    [WebMethod]
    public WeekDay GetWeekDay()
    {
        return WeekDay.Fri;
    }
 

ScriptManager:

    <asp:ScriptManager ID="sm" runat="server">
        <Services>
            <asp:ServiceReference Path="~/WebService2.asmx" InlineScript="true" />
        </Services>
    </asp:ScriptManager>

 

页面控件:

    <input type="button" value="Click Me!" onclick="btn_click()" id="btn" />
    <div id="result">
    
    </div>

 

Js:

    <script type="text/javascript">
        function btn_click(){
            WebService2.GetWeekDay(onSuccessed);
        }
        
        function onSuccessed(result){
                $get("result").innerHTML=result;
        }
        
    </script>
 

结果:

Ajax--WebService返回枚举_第1张图片

 

debugger:

Ajax--WebService返回枚举_第2张图片

你可能感兴趣的:(webservice)