ajax 调用后台的方法
//前臺(tái)的代碼?
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods=true>
??????? </asp:ScriptManager>
??????? <script>
??????? (
??????? function scriptgetdate() {
?????????? PageMethods.getdate(onsuccess);//通過(guò)PageMethod調(diào)用后臺(tái)的方法
??????? }
??????? )();
??????? function onsuccess(message) {//回調(diào)函數(shù)
??????????? $get("message").innerHTML= message;
??????? }
??????? </script>
???//后臺(tái)的方法
?[System.Web.Services.WebMethod]//必須在方法的上面引用[System.web.services.WebMethod]?
??? public static string getdate()
??? {
??????? //return "Hello World!";
??????? return "<font color='red'>"+System.DateTime.Now.ToShortDateString()+"</font>";
??? }????
轉(zhuǎn)載于:https://www.cnblogs.com/Akingshoot/archive/2009/06/27/1512294.html
總結(jié)
以上是生活随笔為你收集整理的ajax 调用后台的方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 09年斯柯达晶锐轮胎是多大尺寸的呢
- 下一篇: 5万块最聪明的理财方式 可以选择这几种