jquery如何调用后台的方法
2009-10-09 17:09
375 查看
小弟想用jquery调用后台方法,但现在返回的整个页面的html代码,请问高手们是什么原因啊,应该怎么改
代码如下
前台 Defalut.aspx
后台 Defaule.aspx.cs
代码如下
前台 Defalut.aspx
复制代码 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <script type="text/javascript" src="jquery.js"></script> <script language="javascript"> $(document).ready(function() { $("#Result").click(function() { $.ajax({ type: "POST", url: "Default.aspx/GetDate",//注意调用方式,同样方式可以调用webservice data: {}, //在这里可以设置需要传递的参数 contentType: "application/json; charset=utf-8", // dataType: "json", success: function(msg) { // 替换返回内容 $("#Result").text(msg); }, error: function(xhr,msg,e) { alert(msg); } }); }); }); </script> </head> <body> <form id="form1" runat="server"> <div id="Result">Click here.</div> </form> </body> </html> |
复制代码 using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; [System.Web.Script.Services.ScriptService] public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } [System.Web.Services.WebMethod] public static string GetDate() { return DateTime.Now.ToString(); } } |
相关文章推荐
- 一个list中包含不同的type时如何遍历?页面如何接收?Jquery调用后台方法?
- jquery异步调用页面后台方法‏(asp.net)
- C# 开发小技巧(一)如何在前台用JavaScript调用后台C#方法
- JQuery .ajax方法直接调用aspx后台代码
- jquery异步调用页面后台方法
- jQuery.ajax()调用asp.net后台方法
- JQuery直接调用asp.net后台WebMethod方法
- asp.net jquery.Ajax() 方法调用后台方法
- jquery与Ajax() 调用后台方法
- jquery.Ajax()方法调用Asp.Net后台的方法解析
- jquery调用asp.net 页面后台方法
- jQuery中使用getJSON方法调用C#的后台方法
- 利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法
- jQuery 调用后台方法
- JQuery调用后台方法
- JQuery的$.ajax()调用asp.net的后台方法样例代码
- jQuery 调用后台方法
- 利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法
- 利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法。
- jquery 调用后台方法